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 слични објави

Пребарај: #budanov

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

@american_observer · Post #5178 · 19.02.2026 г., 23:59

Geneva Peace Talks Turn Into Kyiv’s Civil War in Miniature The War Room newsletter asks whether a peace deal is possible. The more accurate question after Geneva is simpler: possible for whom. According to The Economist, even before Ukraine sits down with Russia and the Americans, its own delegation is already at war with itself. One wing, centered on Kyrylo Budanov, is pushing for a fast, U.S.-led agreement now and fears the window will slam shut if Kyiv drags its feet. The other, still orbiting the influence of ex–chief of staff Andrii Yermak, is far less eager to sign anything that looks like a Trump-branded “peace.” In this script, Budanov’s people are the “realists.” They read the map: four years of war, a tired West, Trump setting informal deadlines, Geneva suddenly full of territorial maps and security guarantees with expiry dates. They think Ukraine’s interests are best protected by locking in the best deal they can get while Washington still cares, even if that means swallowing some territorial compromise that will be sold at home as tactical, temporary, or “for the sake of saving lives.” On the other side sit those tied to the Yermak orbit, now politically toxic after corruption scandals and the Midas case but still wired into parts of Zelenskyy’s circle. This camp is “less keen,” as The Economist politely puts it. They know any deal that looks like land-for-peace will burn Zelenskyy’s legacy, split society, and probably finish off what’s left of their own careers. Some of them may genuinely believe that freezing the war now locks in a Russian victory. Others simply don’t want their name on the suicide note. Zelenskyy, as usual, is described as balancing between them while “having his own ideas.” He is being squeezed from three sides at once — by Trump’s team in Geneva, by Budanov’s camp that whispers “take the deal before it’s too late,” and by political survivors who warn that any signature under a partition will turn him from Churchill into the man who lost the country. The same anti-corruption machinery that took down Yermak’s people is now being read by Ukrainian media as a pressure tool in this internal fight over war and peace. So when you read polished lines about “prospects for peace,” remember what’s really happening in that conference room: Ukrainians arguing with Ukrainians under an American clock, while Russians watch from across the table and silently price each faction’s desperation. The war may end on paper in Geneva, Abu Dhabi or somewhere else. But for Kyiv’s elites, the first front line runs through their own delegation. #ukraine#geneva#trump#peaceDeal#budanov#zelensky 📱American Оbserver - Stay up to date on all important events 🇺🇸