TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #32 · 7 фев.

Скорее всего уже слышали, что складывать строки через + это плохая практика. Падение производительности, и всё такое. Без лишних слов, давайте измерять: from timeit import timeit def t1(): # складываем 10 строк через + из переменной t = 'text' for _ in range(1000): s = t + t + t + t + t + t + t + t + t def t2(): # склеиваем список строк через метод join arr = ['text'] * 10 for _ in range(1000): s = ''.join(arr) def t3(): # складываем через + но не из переменной а непосредственно инлайн объекты for _ in range(1000): s = 'text' + 'text' + 'text' + ... # всего 10 раз Теперь каждую строку склейки запустим по 10М раз >>> timeit(t1, number=10000) 0.21951690399964718 >>> timeit(t2, number=10000) 1.4978306379998685 >>> timeit(t3, number=10000) 0.2213820789993406 Хм, а нам говорили что через "+" это плохо и медленно ))) 😁 Тут стоит учитывать, что речь идёт о склейке множества длинных строк. Давайте изменим условия: def t4(): t = 'text'*100 for _ in range(1000): s = t + t + t + t + t + t + t + t + t def t5(): arr = ['text'*100] * 10 for _ in range(1000): s = ''.join(arr) def t6(): for _ in range(1000): s = 'text'*100 + 'text'*100 + ... # всего 10 раз >>> timeit(t4, number=10000) 12.795130728000004 >>> timeit(t5, number=10000) 2.642637542999182 >>> timeit(t6, number=10000) 0.2184546610005782 Вот, уже другой разговор, сразу видна разница, в среднем в 6 раз. Но погодите, почему последний тест t6() по скорости такой же как и t3()? Ведь строки теперь в 100 раз длиннее! Это вопросы оптимизации кода, какие простые изменения ускоряют или замедляют выполнение программы. Мы столкнулись с примером обхода обращения к переменной. Например, именно так работает директива #define в С++, во время компиляции подставляя значение переменной вместо ссылки на неё. В Python это тоже работает, но часто ли вы сможете встретить такой способ работы со строками? К сожалению, способ почти только теоретический. В целом, тесты показали то, что мы хотели. Делаем выводы самостоятельно. Полный листинг 🌍 #tricks

Резултати

Пронајдени 6 слични објави

Пребарај: #influenza

当前筛选 #influenza清除筛选

#Influenza (flu) spreads easily, but prevention starts with you! Practice these simple healthy habits to stay protected: ✔️Wash your hands regularly with soap under running water ✔️Cover your mouth and nose when coughing or sneezing ✔️Avoid close contact with sick individuals ✔️Clean and disinfect touched surfaces frequently ✔️Visit the nearest healthcare facility if you feel unwell ✔️Wear a face mask in crowded places Protect your family. Protect your community. #FluPrevention#HealthyLiving#NCDCNigeria

#Influenza is a highly contagious respiratory infection that can cause fever, cough, sore throat, body aches, and fatigue. It spreads easily through contact with coughs or sneezes of an infected persons. Protect yourself and your loved ones by: ✔️ Getting the annual flu vaccine ✔️ Practicing good hand hygiene ✔️ Covering your mouth and nose when sneezing or coughing ✔️ Staying home if you’re unwell Early prevention and care save lives! #InfluenzaAwareness#StayHealthy#NCDCNigeria

Influenza spreads faster than you think, don’t let your guard down. A simple cough, a handshake, or even touching a surface can expose you to the flu virus. Stay one step ahead by protecting yourself and those around you. 🛑 Practice good hygiene 😷Cough and sneeze into your elbow 🧼 Clean touched surfaces frequently 🏠 Visit the nearest healthcare facility if you feel unwell Your actions can break the chain of transmission. Stay protected. #FluAwareness#Influenza#StopTheSpread#NCDCNigeria

Cerdas Gunakan Obat

@cerdasgunakanobat · Post #3666 · 20.05.2020 г., 15:54

https://www.instagram.com/p/CAah59lJUpJt1SyIcjSI4F-KFIhgsSSFBw0d380/?igshid=1qvycu8wnl1ll . https://m.facebook.com/story.php?story_fbid=10224747250090873&id=1300855885 . . Assalamualaikum wr wb . . Bapak/Ibu/teman2, jangan lupa besok siang, Kamis, 21 Mei 2020, pukul 13.00 - 14.00 WIB, saksikan siaran LIVE Saya dalam program SEIMAN yang ke-3 bersama dr. Ronny Hadyanto di akun @infokom.farmasi Kami akan "Ngobrol Santai Soal ISPA", kupas tuntas masalah kesehatan tersering dan terbanyak di tengah masyarakat hingga saat ini, termasuk saat Pandemi Covid-19. . . GRATIS dan BERHADIAH SOUVENIR MENARIK dari @inpharcom.bukukesehatan bagi peserta yang bertanya dan beruntung. . . Syaratnya: 1. Follow 3 akun berikut: - @infokom.farmasi - @inpharcom.bukukesehatan - @nellysyukri . 2. Repost flyer ini di akun medsos masing-masing. . 3. Tag/mention minimal 3 akun temanmu. . . Sebarkan yaaa.. . . IG @infokom.farmasi Twitter @infokom.farmasi FB 'Informasi Kefarmasian dan Kesehatan' Email: [email protected] . #infokefarmasian#infokesehatan #inpharcom#bukukesehatan#bukufarmasi#gemacermat#cerdasgunakanobat#ispa#commoncold#batukpilek#influenza#flu#sinusitis#otitismedia#pneumonia#covid19#lawancovid19

Cerdas Gunakan Obat

@cerdasgunakanobat · Post #3665 · 20.05.2020 г., 02:58

Ngobrol Santai Soal ISPA . . https://www.instagram.com/p/CAZMLb9JllK/?igshid=1hbv6y0kyd08y . . https://m.facebook.com/story.php?story_fbid=130671945267435&substory_index=0&id=103148744686422 . . ISPA? Istri Setia Pendiam dan Amanah? Bukaaaannn... Infeksi Saluran Pernapasan Atas? Bukaaaan..... Yang benar ISPA itu Infeksi Saluran Pernapasan Akut. Trus ada apa dengan ISPA? . . ISPA itu salah satu penyakit terbanyak dan tersering dijumpai di tengah masyarakat. Masalahnya apa? Masalahnya, ada banyak jenis ISPA. GAK SEMUANYA BUTUH DIOBATI. DAN GAK SEMUANYA BUTUH ANTIBIOTIK. . . Salah satu gejala ISPA yang jadi momok belakangan ini yaitu Covid-19 yang disebabkan oleh virus SARS-COV2, yang sebenarnya gak ganas. Tapi penyebarannya yang cepat sekali meluas, hingga banyak korban yang tewas. . . Mau tau lebih banyak tentang ISPA? Yuk kita bahas tuntas dalam program SEIMAN yang ke-3 bersama dr. Ronny Hadyanto, dimoderatori langsung oleh Kak @nellysyukri Live di IG @infokom.farmasi Kamis, 21 Mei 2020 Pukul 13.00 - 14.00 WIB. . . GRATIS dan BERHADIAH SOUVENIR MENARIK!! Syaratnya: 1. Follow 3 akun berikut: - @infokom.farmasi - @inpharcom.bukukesehatan - @nellysyukri 2. Repost flyer ini di akun medsos masing-masing. 3. Tag/mention minimal 3 akun temanmu. . . Sebarkan yaaa.. . . IG @infokom.farmasi Twitter @infokom.farmasi FB 'Informasi Kefarmasian dan Kesehatan' Email: [email protected] . #infokefarmasian#infokesehatan #inpharcom#bukukesehatan#bukufarmasi#gemacermat#cerdasgunakanobat#ispa#commoncold#batukpilek#influenza#flu#sinusitis#otitismedia#pneumonia#covid19#lawancovid19