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

Резултати

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

Пребарај: #sgdengueupdate

当前筛选 #sgdengueupdate清除筛选
NEA Singapore

@NEASingapore · Post #701 · 10.11.2023 г., 03:48

#SGDengueUpdate 153 new dengue cases and 53 active dengue clusters were reported in the week ending 4 Nov 2023. If you are living in a dengue cluster area, or have been diagnosed with or are suspected to be infected with dengue,carry out ‘S-A-W’ and ‘B-L-O-C-K’ actions immediately: https://go.gov.sg/mozzieproof ⚠️ Continued urgent action from all is critical to prevent a surge in dengue cases at year-end.

NEA Singapore

@NEASingapore · Post #697 · 02.11.2023 г., 09:37

#SGDengueUpdate 191 new dengue cases and 50 active dengue clusters were reported in the week ending 28 Oct 2023. If you are living in a dengue cluster area, or have been diagnosed with or are suspected to be infected with dengue,carry out ‘S-A-W’ and ‘B-L-O-C-K’ actions immediately: https://go.gov.sg/mozzieproof ⚠️ Continued urgent action from all is critical to prevent a surge in dengue cases at year-end.

NEA Singapore

@NEASingapore · Post #682 · 20.10.2023 г., 00:39

#SGDengueUpdate 215 new dengue cases and 66 active dengue clusters were reported in the week ending 14 Oct 2023. If you are living in a dengue cluster area, or have been diagnosed with or are suspected to be infected with dengue,carry out ‘S-A-W’ and ‘B-L-O-C-K’ actions immediately: https://go.gov.sg/mozzieproof The weekly number of dengue cases has increased steadily, and is expected to rise beyond the traditional peak dengue season, with many dengue clusters across the island. Urgent action from all is critical to prevent a surge in dengue cases at year-end.

NEA Singapore

@NEASingapore · Post #667 · 12.10.2023 г., 09:28

#SGDengueUpdate 267 new dengue cases and 90 active dengue clusters were reported in the week ending 7 Oct 2023. If you are living in a dengue cluster area, or have been diagnosed with or suspected to be infected with dengue,carry out ‘S-A-W’ and ‘B-L-O-C-K’ actions immediately: https://go.gov.sg/mozzieproof ⚠️ The number of dengue cases is expected to rise beyond the traditional peak dengue season, as fast rate of dengue transmission is seen in dengue clusters across the island. Urgent action from all is critical to prevent a surge in dengue cases at year-end.

NEA Singapore

@NEASingapore · Post #655 · 05.10.2023 г., 10:15

#SGDengueUpdate 343 new dengue cases and 76 active dengue clusters were reported in the week ending 30 Sep 2023. No new Zika cases were reported last week. If you are living in a dengue cluster area, or have been diagnosed with or suspected to be infected with dengue,carry out ‘S-A-W’ and ‘B-L-O-C-K’ actions immediately: https://go.gov.sg/mozzieproof

NEA Singapore

@NEASingapore · Post #649 · 28.09.2023 г., 09:14

#SGDengueUpdate 303 new dengue cases and 64 active dengue clusters were reported in the week ending 23 Sep 2023. No new Zika cases were reported last week. If you are living in a dengue cluster area, or have been diagnosed with or suspected to be infected with dengue,carry out ‘S-A-W’ and ‘B-L-O-C-K’ actions immediately: https://go.gov.sg/mozzieproof

NEA Singapore

@NEASingapore · Post #647 · 21.09.2023 г., 09:53

#SGDengueUpdate 330 new dengue cases and 56 active dengue clusters were reported in the week ending 16 Sep 2023. Two new Zika cases were also reported last week. The number of dengue cases at Toa Payoh remains high. If you are living in a dengue cluster area, or have been diagnosed with or suspected to be infected with dengue,carry out ‘S-A-W’ and ‘B-L-O-C-K’ actions immediately: https://go.gov.sg/mozzieproof

NEA Singapore

@NEASingapore · Post #643 · 14.09.2023 г., 09:10

#SGDengueUpdate 261 new dengue cases and 53 active dengue clusters were reported in the week ending 9 Sep 2023. There are two fast-growing dengue clusters at Science Park Drive (47 cases) and Lentor Loop (33 cases). The number of dengue cases at Toa Payoh remains high. If you are living in a dengue cluster area, or have been diagnosed with or suspected to be infected with dengue,carry out ‘S-A-W’ and ‘B-L-O-C-K’ actions immediately: https://go.gov.sg/mozzieproof

NEA Singapore

@NEASingapore · Post #640 · 07.09.2023 г., 10:06

#SGDengueUpdate 213 new dengue cases and 42 active dengue clusters were reported in the week ending 2 Sep 2023. There are two fast-growing dengue clusters at Science Park Drive (26 cases) and Lentor Loop (22 cases). The number of dengue cases at Toa Payoh remains high. Particularly if you are living in a dengue cluster area, or have been diagnosed with or suspected to be infected with dengue,carry out ‘S-A-W’ and ‘B-L-O-C-K’ actions immediately: https://go.gov.sg/mozzieproof

NEA Singapore

@NEASingapore · Post #276 · 26.10.2021 г., 10:16

#SGDengueUpdate Over 4,500 dengue cases have been reported this year, and there are currently 12 active dengue clusters. Although recent weekly dengue cases have been lower than during the same period in 2020, we should all continue to stay vigilant, to prevent a year-end rise in dengue cases amid higher circulation of less common Dengue virus serotype 3 (DENV-3)! Learn how you can prevent Aedes mosquitoes from breeding in your home: www.nea.gov.sg/dengue-zika/prevent-aedes-mosquito-breedin

NEA Singapore

@NEASingapore · Post #155 · 26.01.2021 г., 10:35

#SGDengueUpdate The number of weekly dengue cases has come down slightly to 156 cases as of 23 Jan. However, the Aedes aegypti mosquito is still high in parts of Singapore. Coupled with a sizeable proportion of people still working from home, the risk of dengue remains high in 2021. The strong support from our stakeholders and the public helped to bring down the weekly number of dengue cases from its peak of 1,792 in Jul 2020. Let’s stay vigilant in this fight against dengue! Here’s how: www.nea.gov.sg/stop-dengue

NEA Singapore

@NEASingapore · Post #137 · 03.12.2020 г., 03:41

#SGDengueUpdate 281 weekly dengue cases were reported last week, reversing the downward trend in the number of weekly dengue cases over the past 6 weeks. The Aedes mosquito population has also increased by 11% since the second week of Nov. Let’s all stay vigilant and do our part to reduce the Aedes mosquito population! Learn more: go.gov.sg/mozzieproof

123•••78
ПретходнаСтраница 1 од 8Следна