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

Резултати

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

Пребарај: #supremeleader

当前筛选 #supremeleader清除筛选
Crypto M - Crypto News

@CryptoM · Post #65253 · 12.04.2026 г., 10:35

🚀 Iran's Foreign Policy Focuses on National Protection, Adviser States Iran's Supreme Leader's foreign affairs adviser, Velayati, stated on his social media platform on the 12th that Iran's foreign policy consistently adheres to the principle of 'protecting our homeland.' According to Odaily, he emphasized that control over the Strait of Hormuz is firmly in Iran's hands. #Iran#ForeignPolicy#NationalProtection#StraitOfHormuz#Velayati#SupremeLeader#HomelandProtection

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40796 · 14.03.2026 г., 20:05

Mojtaba Khamenei became Supreme Leader of Iran after his father, Ali Khamenei, was killed in a U.S.–Israeli airstrike. He leads with hard-line policies, controlling the military, security forces, and political decisions. For ordinary Iranians, this means strict government control, limited political freedom, limited internet, harsh enforcement of laws, and continued tensions with the West. Daily life and dissent will likely remain tightly restricted under his rule. 🕌🇮🇷⚔️ [Read more] @googlefactss #Iran#MojtabaKhamenei#SupremeLeader#politics#newsfacts#freeIran#protests#womensrights

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40731 · 03.03.2026 г., 17:02

Ali Hosseini Khamenei was born on 19 April 1939 in Mashhad, Iran. He was a Shiite cleric and political leader. He took part in the 1979 Iranian Revolution. He later became President of Iran from 1981 to 1989 during the Iran–Iraq War. On 4 June 1989, after the death of Ruhollah Khomeini, he was chosen as the 2nd Supreme Leader of Iran. He held this role until 28 February 2026. As Supreme Leader, he had authority over the military, judiciary, state media, intelligence services, and foreign policy. He oversaw Iran’s nuclear program and strengthened the Islamic Revolutionary Guard Corps. His government carried out crackdowns on protests and dissent. He was reported killed on 28 February 2026 during Israeli missile attacks in Tehran. His death was confirmed on 1 March 2026. His son is replacing him. 🏛️🇮🇷📜 [Read more] @googlefactss #AliKhamenei#Iran#SupremeLeader#dictator#IranHistory#MiddleEast#freeIran#LiberateWomen#protest