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

Резултати

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

Пребарај: #tadesse

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

@addisstandardeng · Post #21958 · 07.04.2026 г., 07:24

News: At last day of its mandate, #Tigray interim administration president meets #PM_Abiy to present annual report On the last day of its mandate, President of the Tigray Interim Administration, Lt. Gen. #Tadesse Worede, met Prime Minister Abiy Ahmed this morning to present his annual report, according to a brief statement from the Prime Minister’s Office. The statement shared by the PM Office said the meeting focused on receiving the report and discussing its findings, but did not disclose details of the content or outcomes of the discussion. The meeting comes exactly one year after Lt. Gen. Tadesse was appointed on April 8, 2025, to lead the interim administration in the Tigray Region, replacing Getachew Reda. Prior to his appointment, Tadesse served as deputy president of the interim administration and head of its cabinet secretariat for peace and security......... https://www.facebook.com/AddisstandardEng/posts/pfbid026T2zp6KVZ5rdVCzYZ2etaSMRY3C9WWRNS9efDwjLTJFpQoVASVTBXr7Xn4nfbWudl

Addis Standard

@addisstandardeng · Post #21693 · 12.03.2026 г., 13:51

#Ethiopia: Preparedness is vital’: #Tigray President warns against ‘living in defeat’ at Emperor Yohannes IV commemoration During the 137th anniversary of the martyrdom of #Emperor_Yohannes IV, Lieutenant General #Tadesse Wereda, President of the Interim Administration of Tigray, delivered a sobering address, emphasizing that while peace remains the priority, the region must remain prepared for any eventuality. The President acknowledged that this year’s remembrance comes at a precarious time. He described the current atmosphere not as one of comfort, but as one defined by "heavy political tension." "We are carefully nurturing the relative peace we have in our hands," President Tadesse stated. "However, there are circumstances where forces beyond your capacity emerge, forcing you to make decisions you would not otherwise choose." In a pointed message regarding the region's security & political stance, the President underscored that peaceful options must...... Read more: https://addisstandard.com/?p=55799

Addis Standard

@addisstandardeng · Post #21270 · 01.02.2026 г., 15:14

#Ethiopia: Interim President says dialogue under #Pretoria Agreement remains possible as #Tigray forces withdraw from Tselemti Tigray advanced forces have withdrawn from #Tselemti in what the Tigray Interim Administration described as a confidence-building measure aimed at demonstrating readiness for dialogue and a peaceful resolution to the current tensions, Interim President Lt. General #Tadesse said. “Our withdrawal shows clearly that we have no desire to return to war,” General Tadesse said, adding that “there is no question that can be answered by war, but by peace and negotiation.” Speaking on Saturday to Tigrai Television, he stressed that the situation does not have to escalate into full-scale conflict, emphasizing that dialogue remains both possible and preferable. The Interim President said Tigray’s core demands remain unchanged, centering on the return of internally displaced persons (#IDPs) and the restoration ..... Read more: https://addisstandard.com/?p=54888