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

Резултати

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

Пребарај: #tsedalelemma

当前筛选 #tsedalelemma清除筛选
Addis Standard

@addisstandardeng · Post #22098 · 23.04.2026 г., 16:32

#Premiering_now: From Newsroom to Frontline: Mistresillasie on Power, War & Resistance #TsedaleLemma speaks with #MistresillasieTamrat. Click here to watch: https://www.youtube.com/watch?v=JCF8w7rEYhQ #TheStandardSignal#EthiopiaPolitics#Misteresillasie#ElectionDebate #PoliticalVoices#WomenInPolitics

Addis Standard

@addisstandardeng · Post #22096 · 23.04.2026 г., 14:39

#Coming_UP: The Standard Signal | Ep.17: From Newsroom to Frontline: Mistresillasie on Power, War & Resistance #TsedaleLemma speaks with #MistresillasieTamrat. From her striking statement, “politics took journalism away from me,” to her defense of possible participating in upcoming elections, Mistresillasie speaks with clarity. Premiers at: 7:30 PM EAT tonight. Subscribe to watch: https://www.youtube.com/@AddisStandard #TheStandardSignal#EthiopiaPolitics#Misteresillasie#ElectionDebate #PoliticalVoices#WomenInPolitics

Addis Standard

@addisstandardeng · Post #21333 · 06.02.2026 г., 14:33

#Coming_UP: The Standard Signal |Ep. 12 - Western Tigray and the Unraveling of Ethiopia’s Constitution. Part I Five years after the war in Tigray began, and three years after Pretoria, Western Tigray remains the clearest sign that Ethiopia’s war has not truly ended, it has merely changed form. If peace doesn’t restore rights, is it really peace? If people cannot return safely and with dignity, what does return even mean? Is Ethiopia still governed by its Constitution? #TsedaleLemma speaks with #DanielBerhane. Part I premiers at: 7:30 PM tonight. Subscribe to watch: https://www.youtube.com/@AddisStandard #Ethiopia, #Tigray#WesternTigray#ConstitutionalOrder#PeaceAndJustice#IDPRights#RuleOfLaw#HornOfAfrica#PostPretoria

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

Addis Standard

@addisstandardeng · Post #21515 · 24.02.2026 г., 14:36

#Coming_UP: The Standard Signal | Ep. 13 - The UK’s “New Africa Approach”: Press Freedom, Human Rights, Investment, Migration, and Power Politics in Ethiopia What’s actually new about the UK’s “New Africa Approach”? #TsedaleLemma speaks with #LukeBullock Premiers at: 7:30 PM EAT tonight. Subscribe to watch: https://www.youtube.com/@AddisStandard #TheStandardSignal#UKAfricaPolicy#UKInEthiopia#HornOfAfrica#Geopolitics#DevelopmentAndSecurity#ForeignPolicy#Ethiopia#RedSea#Tigray#Eritrea#Somaliland#Israel

Addis Standard

@addisstandardeng · Post #21239 · 29.01.2026 г., 13:37

#Coming_UP: The Standard Signal | Ep. 11: Meles Zenawi’s Nightmare Revisited: GERD, Gulf Money, and the Unmaking of Sovereignty Fifteen years ago, Ethiopia’s late Prime Minister Meles Zenawi warned that his nightmare would be an “Egyptian agenda financed by Gulf money.” Has Meles Zenawi’s nightmare already arrived? #TsedaleLemma speaks with #JawarMohammed. Premiers at: 7:30 PM tonight. Subscribe to watch: https://www.youtube.com/@AddisStandard #GERD#HornOfAfrica#Ethiopia#GulfPolitics#UAE#SaudiArabia#NilePolitics#AfricanGeopolitics#Sovereignty#MiddleEastAfrica#TheStandardSignal

Addis Standard

@addisstandardeng · Post #21935 · 03.04.2026 г., 14:30

#Coming_UP: The Standard Signal | Ep.15: Ethiopia Under Pressure: Fuel Crisis, Global & Regional Instability, a Fragile Election | Jawar Mohammed #TsedaleLemma speaks with #JawarMohammed about the growing challenges facing Ethiopia, from global and regional tensions to domestic instability, corruption and Ethiopia’s fragile election. Premiers at: 7:30 PM EAT tonight. Subscribe to watch: https://www.youtube.com/@AddisStandard #AddisStandard#TheStandardSignal#Ethiopia#JawarMohammed#EthiopiaPolitics#Corruption#FuelCrisis#HornOfAfrica#Tigray#Amhara#Oromia#EthiopiaElection#AfricaPolitics#EthiopiaNews#AfricanPolitics#Geopolitics