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

Пребарај: #gadaa

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

@addisstandardeng · Post #21347 · 09.02.2026 г., 10:47

#Tribute: Professor Asmarom Legesse: Pioneer Scholar Who Illuminated the #Gadaa System to the World Professor Asmarom Legesse, the Eritrean-born anthropologist who redefined African democratic discourse, passed away on January 31, 2026, aged 94. In this tribute, Teferi Tafa notes the Harvard-trained scholar "spent over half a century documenting the #Oromo Gadaa system, dismantling colonial myths that dismissed indigenous #African governance as primitive." The author explains that Asmarom’s works revealed "a sophisticated constitutional order" featuring rotational leadership and term limits. He proved that Gadaa was "a highly developed system of checks and balances... that had governed Oromo society for centuries." Tafa emphasizes that Asmarom’s legacy of "intellectual decolonization" establishes him as a hero to the Oromo and a titan of global anthropology. https://addisstandard.com/?p=55081

Addis Standard

@addisstandardeng · Post #21319 · 05.02.2026 г., 12:15

#In_Memoriam: A Tribute to Professor Asmarom Legesse Asmerom Legesse (PhD), a pioneering scholar of the #Oromo Gadaa system, passed away at the age of 94. Born on 5 February 1931 in #Eritrea, he was widely respected for his rigorous and sustained studies of Oromo governance, now foundational to #African indigenous political thought. In this tribute, Ezekiel Gebissa writes that “for the Oromo people… death is not an ending but a passage from the world of binary reality to the realm of singularity.” Over nearly six decades, Asmerom reshaped African political studies by showing that #Gadaa is “not a relic of the past but a sophisticated, stable, and coherent democratic system.” Asmerom’s legacy remains the cornerstone of Oromo studies and global indigenous governance. https://addisstandard.com/?p=55020

Addis Standard

@addisstandardeng · Post #21309 · 04.02.2026 г., 14:38

News: Prominent #Oromo Gadaa scholar Asmerom Legesse passes away at 94 Asmerom Legesse (PhD), a distinguished scholar renowned for his pioneering research on the Oromo #Gadaa system, has passed away at the age of 94. Born on 5 February, 1931, in #Eritrea, Asmerom was widely recognized for his in-depth studies of Oromo traditions and governance, which have become foundational references for scholars of #African indigenous systems. In a statement, the Oromo Studies Association (#OSA) confirmed his death, expressing deep sorrow over the loss of a researcher described as a “kinsman of the Oromo people.” The association noted that Asmerom’s work on Oromo customs, history, and culture significantly advanced understanding of political and social systems across Africa. The Oromia Culture and Tourism Bureau expressed deep condolences, emphasizing that his life’s work preserved the Oromo Gadaa system and documented its practices for future generations, serving as.... Read more: https://addisstandard.com/?p=54991