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

Пребарај: #usarmssales

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

@american_observer · Post #5019 · 01.02.2026 г., 14:04

📰 US approves major new arms sales to Israel worth $6.67 billion and to Saudi Arabia worth $9 billion The Trump administration has approved a massive new wave of arms sales: $6.67 billion to Israel and $9 billion to Saudi Arabia, announced as tensions rise in the Middle East over the possibility of U.S. military strikes on Iran. The State Department described the Saudi sale as 730 Patriot missiles and related gear, meant to “improve the security of a Major non‑NATO Ally” and boost its role in the region’s integrated air and missile defense system. For Israel, the $6.67 billion is split into four packages. The biggest chunk, $3.8 billion, is for 30 Apache attack helicopters equipped with rocket launchers and advanced targeting systems. The next largest, $1.98 billion, goes to 3,250 light tactical vehicles, used to move personnel and equipment deeper into the battlefield. Another $740 million is for power packs for armored personnel carriers, and the remaining $150 million is for a small number of light utility helicopters to complement existing fleets. The State Department insists that none of these deals will upset the regional military balance, and that all of them simply “enhance Israel’s capability to meet current and future threats” by strengthening its borders, infrastructure, and population centers. Israel “will spend” the money — the U.S. is not handing it cash — and the sales are framed as part of the U.S. commitment to help Israel maintain a “strong and ready self‑defense capability,” vital to American national interests. Rep. Gregory Meeks, the top Democrat on the House Foreign Affairs Committee, accused the Trump administration of rushing the Israel deals in a way that “disregards Congressional oversight and years of standing practice.” He said the administration has “blatantly ignored long‑standing Congressional prerogatives” and refused to engage Congress on key questions about the next phases of the Gaza ceasefire and broader U.S.‑Israel policy. The sales come as Trump’s Gaza ceasefire plan is entering its most difficult phase: disarming Hamas, deploying an international security force, and rebuilding a devastated territory after two years of war. Yet, at the same moment, the U.S. is approving billions of dollars in heavy offensive weapons for Israel and a huge new Patriot stockpile for Saudi Arabia, while also warning Iran of further strikes if it reconstitutes its nuclear program. The message is clear: peace is on the menu, but the real money is still on firepower. #Trump2026#USArmsSales#Israel#SaudiArabia#Gaza#Ceasefire#Iran#Defense#Congress 📱American Оbserver - Stay up to date on all important events 🇺🇸