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

Резултати

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

Пребарај: #iraq

当前筛选 #iraq清除筛选

伊拉克的藥材鋪 (地點: Karbala) Karbala 是巴格達以南一百公里的一個什葉派聖城。 基本上,全世界有草本植物的地方,也有自己一套的經驗醫學和本草綱目。伊拉克的「米索不達美亞」是暫時考古之中, 承認的最早出現系統及文字的人類文明, 那時他們已經懂得「做手術」。 #Iraq

Hashtags

POPULAR FRONT

@popularxfront · Post #6196 · 08.05.2026 г., 16:27

🇮🇶#Iraq: Hajaj Ahmed Hardan al-Tikriti, widely known among survivors as "Saddam Hussein’s personal butcher" was brought before the Rusafa Criminal Court in Baghdad over crimes linked to the Anfal genocide against the Kurds. A former warden at the notorious Nugra Salman prison in Iraq’s southern Muthanna province, he is accused of overseeing torture and carrying out executions, forced disappearances, starvation, and the abuse of thousands of Kurdish detainees during the late 1980s. Since his arrest on July of last year, after decades in hiding, al-Tikriti has appeared multiple times before the Rusafa Court in connection with atrocities committed at Nugra Salman prison. Around 221 relatives of Anfal victims from several Kurdish regions attended the court session wearing traditional Kurdish clothing, demanding justice for the massacres and crimes committed against the Kurdish population. Attached footage shows Hajaj in handcuffs next to the Nugra Salman Prison. (via Rudaw & @kurdishactivism_ on IG)

Hashtags

POPULAR FRONT

@popularxfront · Post #6080 · 29.04.2026 г., 06:56

🇮🇶#Iraq: The “Guardians of Blood Brigades” have struck a communication tower at the US Victoria Base in Baghdad using a fiber-optic drone armed with an RPG warhead. (via @war_noir)

Hashtags

POPULAR FRONT

@popularxfront · Post #6002 · 24.04.2026 г., 01:17

🇮🇶#Iraq: The Kurdistan National Army headquarters in Chamshari was struck by a drone last night. So far, no information has been released regarding who launched the attack. (via @KurdishFrontNews)

Hashtags

POPULAR FRONT

@popularxfront · Post #5989 · 22.04.2026 г., 21:10

🇮🇶#Iraq: Footage showing drone interceptions over Erbil in Iraqi Kurdistan after an alleged massive drone attack.

Hashtags

POPULAR FRONT

@popularxfront · Post #5850 · 10.04.2026 г., 09:18

🇮🇶#Iraq: Footage shows US forces attempting to shoot down drones over Erbil Governorate in Iraq's Kurdistan overnight. Several reports state that the drones belong to Iran-backed militias, with one of the most active groups in Iraq lately being the Guardians of Blood Brigades. (via Archer83Able on X)

Hashtags

POPULAR FRONT

@popularxfront · Post #5817 · 08.04.2026 г., 07:59

🇮🇶#Iraq: The "Islamic Resistance in Iraq" has carried out several attacks against US bases in Iraq, as well as in the Kurdistan Region, overnight. The militants used cruise missiles and kamikaze drones in the attacks. (via @war_noir)

Hashtags

POPULAR FRONT

@popularxfront · Post #5728 · 02.04.2026 г., 23:30

🇮🇶#Iraq: Footage released by the Islamic Resistance in Iraq (IRI) shows a drone strike targeting a fuel tank at the US Victory Camp base near Baghdad Airport. (via @conflictarchive)

Hashtags

123•••10•••202122
ПретходнаСтраница 1 од 22Следна