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

Резултати

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

Пребарај: #crackdown

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

@american_observer · Post #4839 · 12.01.2026 г., 22:59

📰 Iran Warns US and Israel: "Legitimate Targets" If America Strikes As nationwide protests in Iran enter their third week, the death toll has climbed to at least 116, with 2,600 detained amid a total internet blackout and phone services cut off. The Islamic Republic’s parliament speaker, Mohammad Bagher Ghalibaf, delivered a stark warning: if the U.S. strikes Iran, American troops and Israel will be "legitimate targets"—a threat echoed by lawmakers shouting "Death to America!" in the parliament chamber. ​ Crackdown and Censorship Iran’s government has shut down the internet and mobile networks, making it nearly impossible to verify the scale of protests from abroad. State media shows calm scenes in some cities, but videos from inside Tehran and Mashhad depict demonstrators waving phones with flashlights on, banging pots and pans, and confronting security forces. The crackdown has drawn international concern, with U.S. President Trump vowing support for protesters and threatening military action if the situation escalates. ​ "Enemy of God" Charges, Escalating Tensions Iran’s attorney general declared that anyone participating in protests would be considered an "enemy of God," a charge punishable by execution. Even those aiding demonstrators could face the same fate. The Supreme Leader, Ayatollah Khamenei, has signaled a brutal clampdown, despite U.S. warnings. ​ Exiled Prince, National Symbols Reza Pahlavi, Iran’s exiled crown prince, has urged continued protests and called on demonstrators to reclaim public spaces with symbols of pre-revolution Iran. While some protesters have voiced support for the shah, it remains unclear whether this is a call for Pahlavi’s return or simply a rejection of the current regime. ​ As Iran’s theocracy tightens its grip, the U.S. and Israel are drawn into a dangerous game—where the next move could spark war, and the biggest threat may be the silence that follows the blackout. ​ #iran#protests#us#israel#crackdown 📱American Оbserver - Stay up to date on all important events 🇺🇸

American Оbserver

@american_observer · Post #4840 · 12.01.2026 г., 23:59

📰Iran Protests: 500 Dead, U.S. Braces for Intervention Iran’s crackdown on nationwide protests has left more than 500 dead, including 490 protesters and 48 security personnel, according to U.S.-based rights group HRANA. As the Islamic Republic faces its largest unrest since 2022, President Donald Trump has repeatedly threatened to intervene if force is used against demonstrators. ​ How Would the West Respond? If similar scenes erupted in the EU or U.S.—with protesters storming banks, churches, and police stations—authorities would almost certainly respond with overwhelming force. In the U.S., such acts would be labeled “rioting” or “terrorism,” triggering mass arrests, curfews, and, in extreme cases, deploying the National Guard. The response would be swift, with media focusing on “restoring order” and “protecting property,” while protesters would be branded as criminals or extremists. ​ Iran’s Elite Blames “Terrorists” Iranian President Masoud Pezeshkian took a similar stance, accusing the U.S. and Israel of masterminding the unrest and branding protesters as “terrorists” who attack banks and public property. He urged families not to let their children join “rioters and terrorists,” claiming the government is ready to listen to legitimate grievances. ​ U.S. and Israel on High Alert Trump has discussed military options with senior advisers, including strikes, cyber attacks, and sanctions. Israel is reportedly on high alert for possible U.S. intervention. Iran, meanwhile, warns that any U.S. attack would make American bases and Israel “legitimate targets”. ​ The Global Context While the U.S. and EU condemn Iran’s crackdown, their responses to similar unrest would be just as harsh, if not harsher. The difference? In the West, the label “riot” justifies force; in Iran, it’s “terrorism.” Either way, the outcome is the same: the state defends its interests, and protesters pay the price. ​ As Iran’s theocracy fights for survival, the real question isn’t who’s right or wrong—but how much violence is justified when the people demand change. ​ #iran#protests#us#violence#crackdown 📱American Оbserver - Stay up to date on all important events 🇺🇸