@TFGames · Post #2172 · 16.02.2024 г., 21:41
#PANDEMIC #8 #BALL#POOL#GAMES https://testflight.apple.com/join/fFYcLcjG
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
Пребарај: #pandemic
@TFGames · Post #2172 · 16.02.2024 г., 21:41
#PANDEMIC #8 #BALL#POOL#GAMES https://testflight.apple.com/join/fFYcLcjG
@reutersworldchannel · Post #149253 · 12.10.2021 г., 14:32
Bali surf school owner eagerly awaiting imminent return of foreign tourists A Bali surf school owner is pinning hopes on Indonesia's plan to reopen the island to some foreign tourists from mid-October, after her business suffered due to a lockdown. #Bali#Indonesia#Lockdown#Pandemic#BaliSurfing#Tourism#News#Reuters Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖
@reutersworldchannel · Post #149302 · 13.10.2021 г., 13:17
October 13, 2021: Gabby Petito, Texas Governor, Debt ceiling fix, U.S borders, La Palma Volcano October 13, 2021: Gabby Petito, Texas Governor, Debt ceiling fix, U.S borders, La Palma Volcano 1. Gabby Petito, the young woman who vanished on a road trip with her boyfriend and later turned up dead in Wyoming, was killed by strangulation, a local coroner said. 2. Texas Governor Greg Abbott's ban on COVID-19 vaccine mandates will likely be superseded by the Biden administration's plan to require shots for workers, but the dueling rules could take months to sort out in court, creating uncertainty for employers with business in the state. 3. The Democratic-controlled U.S. House of Representatives gave final approval to legislation temporarily raising the government's borrowing limit to $28.9 trillion, pushing off the deadline for debt default only until December. 4. The United States will lift restrictions at its land borders with Canada and Mexico for fully vaccinated foreign nationals in early November, ending historic curbs on non-essential travelers in place since March 2020 to address the COVID-19 pandemic. 5. Over 700 residents were ordered to abandon their homes on the Spanish island of La Palma as red-hot lava advanced towards their neighborhood. #GabbyPetito #Wyoming #TexasGovernor #Covid19 #Vaccines #Biden #Democrats #Republicans #UnitedStates #Debt #Canada #Mexico #Borders #Pandemic #LaPalma #Spain #Volcano #News #Reuters Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖