@teasticker · Post #9559 · 14.04.2022 г., 18:00
#moe_sticker_bot#fury#animated
Hashtags
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
Пребарај: #fury
@teasticker · Post #9559 · 14.04.2022 г., 18:00
#moe_sticker_bot#fury#animated
Hashtags
@teasticker · Post #9451 · 20.03.2022 г., 15:00
#moe_sticker_bot#fury#cat#animated
@american_observer · Post #5384 · 15.03.2026 г., 15:30
Trump: Iran Will Be Attacked As Necessary Trump said on Saturday that the United States may carry out more strikes on Iran’s vital Kharg Island oil export hub “just for fun”, rejecting the prospect of a swift peace deal with Tehran. “The terms aren’t good enough yet,” the US president told NBC News. The Iranian regime wants to make an agreement, he claimed. After days of conflicting messaging from the White House on how much longer it will continue to wage war on Iran, Trump alleged that US strikes had “totally demolished” most of Kharg Island, and told the network that its military may hit site “a few more times just for fun”. “We’ve totally decimated it,” he said. “Except, as you know, I didn’t do anything having to do with the energy lines, because having to rebuild that would take years.” The president also questioned, without attribution, whether Iran’s new supreme leader Mojtaba Khamenei “is even alive” amid speculation over his condition. Trump also said it’s not clear whether Iran has dropped mines in the strait of Hormuz, which has been all but closed since the start of the conflict two weeks ago, in the 30-minute telephone call with NBC. The strait is a vital waterway in world trade, with about a fifth of crude oil typically passing through it. Concerns over the impact of the US-Israel war on Iran on global energy supplies, intensified by the strait’s paralysis, have propelled oil prices to their highest levels in four years. This has swiftly driven up fuel prices right across the world, including in the US. “We’re going to be sweeping the strait very strongly, and we believe we’ll be joined by other countries who are somewhat impeded, and in some cases impeded from getting the oil,” Trump said. It is unclear how long this process will take. He did not state which countries would join the US in this task. The president also renewed his call earlier on Saturday for other nations to help secure the strait of Hormuz and said the US will coordinate with them amid the US-Israeli war on Iran. “The United States of America has beaten and completely decimated Iran, both Militarily, Economically, and in every other way, but the Countries of the World that receive Oil through the Hormuz Strait must take care of that passage, and we will help – A LOT,” Trump wrote in a Truth Social post. He added that “the US will also coordinate with those Countries so that everything goes quickly, smoothly, and well. This should have always been a team effort, and now it will be – It will bring the World together toward Harmony, Security, and Everlasting Peace!” But he later declined to say whether the US Navy would be escorting ships. “I don’t want to tell you anything about that,” he told NBC. Trump’s assertion that the crisis in the strait of Hormuz should be resolved through a “team effort” could be seen as somewhat of a pivot from his earlier position that Operation Epic Fury was a US show of force, alongside Israel, that didn’t require international permission. The president also expressed surprise in the interview that US allies in the Gulf have been targeted by Iran. These countries “got shot at unnecessarily”, he told NBC, describing Iran’s decision to target them as “the biggest surprise I had of this whole thing”. #trump#iran#ttacks#necessary#epic#fury 📱American Оbserver - Stay up to date on all important events 🇺🇸
@teasticker · Post #9575 · 18.04.2022 г., 10:00
#KakaoStickerBot#fury#Avengers#animated
@teasticker · Post #9298 · 22.02.2022 г., 07:41
#Kaomoji#white#gestures#fury#animated
@teasticker · Post #9163 · 03.02.2022 г., 04:00
Satanichia McDowell 😠 #Satanichia#Otakuzdream#fury#chan#girl#anime #愤怒#酱#女孩#动漫
@teasticker · Post #9415 · 10.03.2022 г., 07:31
Funny Cat 🤪 #FunnyCatspack#fury#grin#cat#animated #愤怒#鬼脸#猫#动画
@teasticker · Post #9302 · 22.02.2022 г., 07:41
Cursed Emojis 💔 #CursedEmojis#crying#fury#emojis#animated #哭泣#愤怒#表情#动画
@teasticker · Post #9916 · 09.07.2022 г., 09:30
Little Blue Elephant 🙎♀️ #LittleBlueElephant_videi#fury#blue#eleplant#animated #愤怒#蓝色#像#动画
@teasticker · Post #9487 · 26.03.2022 г., 03:12
Telegramka 😠 #TheMascot#fury#fire#dog#animated #愤怒#火焰#狗#动画
@teasticker · Post #9730 · 12.05.2022 г., 19:40
ConorAnimated 😡 #ConorAnimated#fury#confused#man#animated #愤怒#纠结#男人#动画
@teasticker · Post #9480 · 25.03.2022 г., 16:10
Human Box 😡 #HumanBox#fury#lego#man#animated #愤怒#乐高#男人#动画