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

Резултати

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

Пребарај: #gulfsecurity

当前筛选 #gulfsecurity清除筛选
Red Nile

@rednile12 · Post #11104 · 28.02.2026 г., 13:23

🔺Continuation from above @rednile12 📌 What Happened Earlier Today Earlier on February 28, 2026, the United States and Israel launched a coordinated military offensive against multiple targets in Iran — an operation involving aerial and missile strikes planned over weeks, according to Israeli officials. Western powers claimed the operation aimed to neutralize what they described as “existential threats” posed by Iran’s missile and nuclear programs. However, Russia and others have condemned the U.S.–Israel assault as a premeditated, unprovoked act of aggression against a sovereign state. 🔥 Iran’s Retaliatory Tactics Iran’s response appears to reflect a strategic approach, not a spontaneous counterattack: 🔹Missile Barrages First: Iran fired ballistic missiles at multiple targets hosting U.S. forces and allied positions across the Gulf — including Qatar, Bahrain, Kuwait, and the UAE. 🔹Drone Saturation: Following the missile salvos, waves of Shahed-136 drones were reportedly used to strike high-value U.S. radar and defense infrastructure once expensive interceptor systems were already engaged. 🔹 This layered method has key implications: ▪️ It forces U.S. and allied defenses to expend high-cost interceptors against cheaper threats. ▪️ It exploits cost asymmetry, where low-cost drones can wear down advanced systems economically and tactically over time. ▪️ It demonstrates Iran’s ability to integrate UAVs into broader retaliation campaigns, not just standalone strikes. 🧠 Strategic Takeaways 📍Damage to Early Warning Capabilities If U.S. AN/FPS-132 radars are seriously degraded or destroyed, it would reduce the effectiveness of missile tracking and early warning across the region, complicating air defense coordination in a rapidly evolving war environment. 📍Cost Imbalance in Modern Air Defense Iran’s combination of missiles and inexpensive drones highlights a structural weakness in defense architectures built around costly interceptor munitions. 📍Regional Escalation Risks Today’s retaliation underscores how quickly localized strikes can escalate into broader conflict — dragging multiple Gulf states into direct confrontation, disrupting airspace, and threatening civilian infrastructure across the region. ♦️This is no ordinary exchange of fire — it reflects a turning point in regional warfare dynamics, where retaliation, sequencing, cost imbalances, and strategic targeting have dramatic implications for how future conflicts unfold. RedNile Media🌊🧭 📡@rednile12 Geopolitics | Multipolarity | Sovereignty | Strategic Reality #Iran#USA#Israel#MiddleEastCrisis#GulfSecurity