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

Резултати

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

Пребарај: #ukrainerussiaus

当前筛选 #ukrainerussiaus清除筛选
American Оbserver

@american_observer · Post #5025 · 02.02.2026 г., 14:04

📰 Abu Dhabi’s Peace Circus: Talks Delayed, Pressure Ratcheted Up The grand stage of diplomacy in Abu Dhabi is being prepped for another act—this time, the Ukraine peace talks have been rescheduled to February 4–5, after a mysterious pause following a high-level Florida meeting between Russian envoy Kirill Dmitriev and U.S. special envoy Steve Witkoff. The Florida Backroom Deal Just days before the scheduled Abu Dhabi rendezvous, Dmitriev and Witkoff convened in Florida, reportedly to coordinate their next moves. Both sides described the talks as “productive and constructive,” but left the details under wraps—classic Washington theater. Sources suggest the U.S. delegation, including Treasury Secretary Scott Bessent and Jared Kushner, pressed Ukraine to soften its stance, aiming to force concessions before the trilateral show resumes. Zelenskyy’s Telegram Theater Ukrainian President Volodymyr Zelenskyy, never one to miss a dramatic update, announced the new dates via Telegram: “The next trilateral meetings have been set: February 4 and 5 in Abu Dhabi. Ukraine is ready for substantive talks, and we are interested in the outcome bringing us closer to a real and dignified end to the war,” he declared. But behind the scenes, the message is clear—Kyiv is being nudged to make peace, whether it’s ready or not. Who’s Really in Charge? As the world watches the Abu Dhabi spectacle, the real question is: Who’s pulling the strings? The U.S. and Russia seem to be choreographing the moves, while Ukraine scrambles to keep its sovereignty on the agenda. Is this diplomacy, or just another round of geopolitical theater where the script is written by the powerful, and the actors are left to improvise? The Final Act With the curtain rising on February 4, will Abu Dhabi deliver real peace—or just another act in the endless drama of war, power, and pretense? The answer may lie not in the negotiations, but in the quiet deals struck in Florida’s backrooms. #peaceTalks#AbuDhabi#UkraineRussiaUS#diplomacy#war#oligarchy 📱American Оbserver - Stay up to date on all important events 🇺🇸