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 слични објави

Пребарај: #justicedelayed

当前筛选 #justicedelayed清除筛选
BadVolf

@badvolfnews · Post #1103 · 07.10.2023 г., 23:25

🔍 Police found no fault in fatal car crash involving Sen. Menendez's wife. Investigation opened to ensure proper handling by officers. Victim was jaywalking with drugs and alcohol in his system. Dashcam audio suggests possible intoxication. Democrat senator facing separate bribery charges. Wife not criminally charged. Tragic accident under scrutiny. #Corruption#Politics#JusticeDelayed https://www.foxnews.com/politics/democrat-sen-bob-menendezs-wife-2018-fatal-car-crash-nj-ags-microscope-reports Subscribe to @BadVolfNews

Addis Standard

@addisstandardeng · Post #22116 · 25.04.2026 г., 12:06

This is a haunting question that cuts to the heart of Ethiopia’s ongoing cycle of political violence. “What are we giving birth to through all this killing?” In this powerful reflection from The Standard Signal EP.16, the conversation confronts the brutal reality of unresolved killings, missing justice, and the human cost of political conflict—from Negele Borena to Harar to Ambo. Two years after the assassination of Bate Urgessa, the questions of accountability and justice remain painfully unanswered. 🎥 Watch the full episode of The Standard Signal on: https://www.youtube.com/watch?v=gAXvr9JN3Y8 #BateUrgessa#Ethiopia#JusticeDelayed#HumanRights#PoliticalViolence#TheStandardSignal#NeverForget

Addis Standard

@addisstandardeng · Post #22050 · 17.04.2026 г., 16:32

#Premiering_now: Two Years Without Justice: Remembering the BrutalAssassination of Bate Urgessa April 9, 2024, a night that ended in a brutal execution a husband, a father of five, an intellectual and a peaceful politician. Two years later, the questions remain. Click here to watch: https://youtu.be/gAXvr9JN3Y8?si=q7C8otTOvcTw_fZ5 In this commemorative episode of The Standard Signal, host Tsedale Lemma discusses with Prof. Ezekiel Gebissa to revisit the life, final hours, and aftermath of Bate Urgessa’s brutal assassination by government forces, and examine what has (and hasn’t) changed since. #BateUrgessa#Ethiopia#JusticeDelayed#HumanRights#Oromo#OLF#PoliticalViolence#Accountability#AfricaNews#HornOfAfrica#TheStandardSignal#NeverForget

Addis Standard

@addisstandardeng · Post #22049 · 17.04.2026 г., 14:53

The Standard Signal Ep 16| Two Years Without Justice: Remembering the Brutal Assassination of Bate Urgessa On April 9, 2024, Bate Urgessa was brutally assassinated by government forces. This special episode revisits the timeline, and what it reveals about justice and political space in Ethiopia today. #TsedaleLemma in conversation with #EzekielGebissa Premiers tonight at 7:30 PM EAT Subscribe to watch: https://youtube.com/@addisstandard #BateUrgessa#Ethiopia#Anniversary#JusticeDelayed#HumanRights#PoliticalViolence#Oromo#OLF#Accountability#HornOfAfrica#TheStandardSignal