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

Резултати

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

Пребарај: #telaviv

当前筛选 #telaviv清除筛选
Marwa Osman/MidEaStream

@Marwa_OsmanLB · Post #3452 · 11.10.2024 г., 19:52

Two bomber drones launched from #Lebanon successfully crossed into occupied Yafa (#TelAviv), with one striking its intended target. A video captures the rapid drone en route to its destination. The Israeli occupation military, in an attempt to downplay the incident, claimed they tracked the drone from Lebanon and intercepted one of them. Sure..yes..we believe you.

İroni Tolışi Rədio

@radiotolishi · Post #9408 · 11.03.2026 г., 16:07

#خبر #ایران #xəbə #Telaviv Telavivədə İroni həmləon nəticədə vironəon ویرانه‌های گسترده تل‌آویو پس از حملات موشکی ایران 💠#رادیو_تالشی💠 ╭──────────╮ 📡@Radiotolishi ╰──────────╯ 💠#Tolışi_Rədio💠

Marwa Osman/MidEaStream

@Marwa_OsmanLB · Post #3209 · 15.09.2024 г., 12:45

A 2000 km Yemeni ballistic missile lands in Tel Aviv as the Israeli military claims it landed in an open area. Initial reports indicated that the missile may have targeted an electricity facility in southeastern. A Multi-Layered Defence Array failed to intercept the attack. #TelAviv. #Yemen

Marwa Osman/MidEaStream

@Marwa_OsmanLB · Post #3335 · 25.09.2024 г., 05:44

#Hezbollah Targets #TelAviv Statement from the Islamic Resistance in #Lebanon In support of our steadfast Palestinian people in the Gaza Strip, and in solidarity with their brave and honorable resistance, as well as in defense of Lebanon and its people, the Islamic Resistance launched a "Qader 1" ballistic missile at 6:30 a.m. on Wednesday, September 25, 2024. The target was the headquarters of Mossad in the outskirts of Tel Aviv, the very site responsible for the assassinations of leaders and the detonation of pagers and wireless devices. "And victory is not but from Allah, the Mighty, the Wise." Wednesday, September 25, 2024 21 Rabi’ al-Awwal 1446 H

Savino Balzano

@savinobalzano · Post #1048 · 15.06.2025 г., 13:50

https://x.com/SavinoBalzano/status/1934246322661457994?t=U3jTWZPtQ4P-IBwdzQ6NqQ&s=19 Suggerisco a tutti quelli che danno per scontate le ragioni di #Israele di guardare questo breve contributo. Non esiste alcuna prova che l'#Iran si stesse dotando di armi nucleari. Nessuna. Per inciso, se ne parla — e si denuncia — da decenni. L'attacco a #Teheran è stato del tutto deliberato e rappresenta una violazione del diritto internazionale. Non è una novità, evidentemente, che #TelAviv agisca in questo modo. Le vere motivazioni dietro l'iniziativa di #Netanyahu risiedono, con ogni probabilità, nella fragilità del suo governo e nelle difficoltà che il Paese incontra nel portare a termine i propri obiettivi. Se ne facciano una ragione i vari Parenzo d'Italia e d'Europa. Sempre meno numerosi, per fortuna.

Turchia e dintorni

@notizieturchia · Post #2923 · 27.12.2024 г., 17:00

#MaherMarwan, nuovo governatore di #Damasco#Siria: "Voglio facilitare le relazioni con #Israele. E' naturale che #TelAviv abbia avuto paura ed è entrata un po' nel territorio siriano e l'abbia un po' bombardato. Non abbiamo problemi con Israele" https://www.npr.org/2024/12/26/nx-s1-5239759/governor-of-damascus-tells-npr-about-the-new-syrian-governments-plans-with-israel

ПретходнаСтраница 1 од 4Следна