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

Резултати

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

Пребарај: #nasrallah

当前筛选 #nasrallah清除筛选
Libertà è ragione

@libertaeragione · Post #4248 · 28.09.2024 г., 08:33

#Israele#Libano Capo di Stato Maggiore dell’#IDF: “La morte di Hassan #Nasrallah non è la fine delle nostre azioni. Il messaggio è semplice: chiunque minacci i cittadini dello Stato di Israele sapremo come raggiungerlo”. @OsservatorioEsteri

Red Nile

@rednile12 · Post #11265 · 15.03.2026 г., 14:14

OSINT leaks - Syrian Mossad spy taking refuge in Lebanon's Ukrainian embassy. A terrorist with Syrian, Ukrainian and Israeli citizenship. He helped in killing Hassan Nasrallah and other terrorist attack. Credits: Journalist Radwan Mortada @cKure #Lebanon#Nasrallah#Mossad#Ukraine#Hezbollah

Marwa Osman/MidEaStream

@Marwa_OsmanLB · Post #4074 · 26.02.2025 г., 07:51

A historic funeral procession was held in Beirut on Sunday for late Hezbollah chiefs Hassan Nasrallah and Hashem Safieddine who were assassinated by Israel late last year. Although Israeli fighter jets flew twice at a low altitude over the hundreds of thousands crowded to mourn the Hezbollah chiefs, the masses stood unwavering chanting “Death to Israel.” #Nasrallah#NasrallahFuneral#Hezbollah#Lebanon#Israel

Marwa Osman/MidEaStream

@Marwa_OsmanLB · Post #4053 · 24.02.2025 г., 21:29

A historic funeral procession was held in Beirut on Sunday for late Hezbollah chiefs Hassan Nasrallah and Hashem Safieddine who were assassinated by Israel late last year. Although Israeli fighter jets flew twice at a low altitude over the hundreds of thousands crowded to mourn the Hezbollah chiefs, the masses stood unwavering chanting “Death to Israel.” #Nasrallah#NasrallahFuneral#Hezbollah#Lebanon#Israel

Marwa Osman/MidEaStream

@Marwa_OsmanLB · Post #3447 · 11.10.2024 г., 17:51

Journalist and geopolitical analyst Fiorella Isabel @FiorellaInMoscow tackles the latest Israeli war crimes in Gaza and Lebanon. She underlines that the assassination of Hezbollah Chief Hassan Nasrallah created more support for the Lebanese group, and that thousands of his likes will be created to fight Israel back. #Hezbollah#Nasrallah#Lebanon#Gaza#Palestine#Netanyahu#Israel

White House Watch

@WhiteHouseWatch · Post #18278 · 17.03.2026 г., 20:58

#Iran L’agenzia stampa Fars, conferma la notizia che il Segretario del Consiglio Supremo per la Sicurezza Nazionale Ali #Larijani sia morto a seguito dell’attacco israeliano. “Ali Larijani, Segretario del Consiglio Supremo per la Sicurezza Nazionale, è stato martirizzato. […] Le anime pure dei martiri hanno accolto l'anima pura di Abdul Saleh God, il martire Dr. Ali Larijani, che, dopo una vita di lotta per il progresso dell'Iran e della Rivoluzione Islamica, ha finalmente realizzato il suo desiderio di lunga data, ha risposto alla chiamata della verità e ha orgogliosamente raggiunto la grazia del martirio nelle trincee del servizio. Egli si unì all'Imam dei Martiri del Ramadan, il Comandante dei Credenti Ali (pace su di lui), e al leader della carovana del martirio e del jihad contro l'America e Israele, Sua Santità l'Ayatollah Seyyed Ali #Khamenei, al suo maestro martire, Sua Santità il Maestro Ayatollah Motahari, e ai suoi compagni martiri Seyyed Hassan #Nasrallah e Hajj Qassem #Soleimani”. @OsservatorioEsteri

Marwa Osman/MidEaStream

@Marwa_OsmanLB · Post #3616 · 11.11.2024 г., 11:56

For the first time, Israeli Prime Minister Benjamin Netanyahu admitted in a cabinet meeting on Sunday that he stands behind several terrorist attacks against Lebanon such as the assassination of Hezbollah chief and the pagers and walkie-talkies attacks. #Hezbollah#Nasrallah#Pagers#UnitedStates#Israel#Netanyahu

Marwa Osman/MidEaStream

@Marwa_OsmanLB · Post #3129 · 25.08.2024 г., 21:05

#Hezbollah Chief Sayyed Hassan #Nasrallah refuted Israeli claims about a preemptive strike ahead of “Operation Al-Arbaeen” in the #Israeli depth. He also set a condition of resuming the retaliation, which has to do with the enemy’s admitting of losses inflicted in first phase. #Lebanon#SouthLebanon#IsraeliArmy

Marwa Osman/MidEaStream

@Marwa_OsmanLB · Post #3247 · 19.09.2024 г., 18:41

In the first remarks after the Israeli terrorist attack against Lebanon, Hezbollah Secretary General Hassan Nasrallah termed the aggression as a declaration of war from the Israeli side. #Hezbollah#Lebanon#Nasrallah#Pagers#Israel#Mossad#Gaza#Palestine

Marwa Osman/MidEaStream

@Marwa_OsmanLB · Post #3122 · 25.08.2024 г., 13:46

Lebanese #Hezbollah military media releases video showing bases targeted in #Israel part of the First Phase of its response to the assassination of senior commander Fuad Shukr and killing of several civilians in #Beirut's southern suburbs on July 31. #Lebanon#SouthLebanon#Nasrallah#Gaza#Palestine#IsraeliArmy

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