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

Резултати

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

Пребарај: #iranwar

当前筛选 #iranwar清除筛选

«جنگ ایران» دگربار نشان داد که تکنولوژی به‌تنهایی نمی‌تواند ژئوپلیتیک را رام سازد و مهار کند. میدان نبرد نه تنها با جنگ‌افزار‌های مدرن، بلکه با جغرافیا نیز تعیین می‌شود. سرنوشت این جنگ چه بسا ممکن است سرانجام به دو گلوگاه ژئوپلیتیکی گره بخورد: تنگه هرمز و باب‌المندب. #IranWar

Hashtags

Borkena

@borkena · Post #6116 · 05.04.2026 г., 19:24

A War Without a Clear Exit: Iran, the United States, and Israel at Week Five. Read more. https://borkena.com/2026/04/05/iran-war-a-war-without-a-clear-exit-iran-the-united-states-and-israel-at-week-five/#Iran#Iranwar#usa

America 🇺🇸 News & Politics

@America · Post #10398 · 19.03.2026 г., 13:05

🚨🇺🇸TRUMP WEIGHS MASSIVE TROOP SURGE TO IRAN WAR ZONE 🔹 Pentagon considers deploying THOUSANDS more troops as Iran conflict hits day 37 — biggest Middle East buildup since Iraq 2003 ⚔️ 🔹 Already ordered: 2,500 Marines aboard USS Tripoli heading to Strait of Hormuz for uranium seizure mission 🚢 🔹 Target: 900 pounds Iranian enriched uranium buried deep underground — Trump calls operation 'very dangerous' 💣 🔹 Public support TANKING: Only 25% of Americans back this war, Pentagon officials dispute intelligence justification 📊 Largest US military presence in Middle East since Bush era — but is America ready for another ground war? 🔥💀 #USNews#IranWar#breaking @america

Bushnell's Men

@BushnellMen · Post #193 · 25.03.2026 г., 14:49

Guess what?! Roaming through American IT market led us to an Israeli company called Netvision. I took the company details from the web. As you can see, Bushnell's poster was on the printing queue three times. And do not forget, while we are watching all these posts, Iranians are getting killed by peace-bringing bombs from above. 💔 #bushnell #Iranwar #Israel

America 🇺🇸 News & Politics

@America · Post #10418 · 24.03.2026 г., 13:02

🚨📊TRUMP APPROVAL HITS IRAN WAR LOW — 40% AS GAS SOARS 🔹 Trump approval drops to 40-42% in new March polls — lowest since Iran war began 🇺🇸🇮🇷 🔹 Gas prices surge to $3.96/gallon after Iran blocks Hormuz Strait — up 35% in one month ⛽💰 🔹 Only 38% approve of his Middle East handling while 67% slam cost-of-living response 📈📉 🔹 $100 fill-ups now reality as oil hits $100/barrel — analysts say no relief until mid-2027 😤⛽ 🔹 92% of MAGA base still supports Iran strikes but independents demand quick exit strategy 🎯🚁 The pump prices are KILLING his numbers — even loyal voters feeling the pinch 💸🔥 #USNews#TrumpPolls#IranWar @america

Borkena

@borkena · Post #6134 · 08.04.2026 г., 02:06

God Save Ethiopia from the Gulf War: The Mechanics of a Fuel-Driven State Collapse. Read more. https://borkena.com/2026/04/07/god-save-ethiopia-from-the-gulf-war-the-mechanics-of-a-fuel-driven-state-collapse/#Ethiopia#IranWar#fuel

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