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

Резултати

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

Пребарај: #amhara

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

@addisstandardeng · Post #22133 · 28.04.2026 г., 11:20

News: Overloaded Isuzu truck carrying dozens atop grain overturns, leaving at least 19 dead in #Amhara region The accident shows the persistent risks associated with the widespread use of cargo trucks for passenger transport in rural Ethiopia, where limited transport options, now exacerbated by chronic fuel shortages across the country, often force residents to travel under dangerous conditions. Many of the victims were residents of the same locality, often traveling together in groups for work between Tsagibji and Ebnat localities. “Yesterday [Sunday] alone, we sent 17 bodies back to one specific area,” the official said, adding that several victims were members of the same families. The Deputy Commander also said the area where the accident occurred has been under the control of Fano fighters for the past three years, preventing authorities from reaching the scene to investigate the cause of the crash. https://addisstandard.com/?p=56655.

Hashtags

Borkena

@borkena · Post #5408 · 30.11.2025 г., 14:16

In Defense of the Amhara Cause: An Open Letter to Mehdi Hasan. Read more. https://borkena.com/2025/11/29/in-defense-of-the-amhara-cause-an-open-letter-to-mehdi-hasan/@mehdirhasan@AJHeadtoHead#Ethiopia#Amhara

Borkena

@borkena · Post #5772 · 08.02.2026 г., 20:38

Targeting the Amhara Intelligentsia: Killings, Detentions, and the Legal Threshold of Genocide Under International Law. Read more. https://borkena.com/2026/02/08/ethiopia-targeting-the-amhara-intelligentsia-killings-detentions-and-the-legal-threshold-of-genocide-under-international-law/#Ethiopia#politics#Amhara

Borkena

@borkena · Post #6090 · 29.03.2026 г., 18:09

Targeted And Forgotten: The Persecution, Displacement, Mass Killing, and Mass Arrest of the Amhara People in Ethiopia . Read more. https://borkena.com/2026/03/29/ethiopia-targeted-and-forgotten-the-persecution-displacement-mass-killing-and-mass-arrest-of-the-amhara-people/#Ethiopia#Amhara#HumanRights

Addis Standard

@addisstandardeng · Post #21844 · 26.03.2026 г., 15:19

#Ethiopia: Federal Police say its forces "seize illegal weapons" intended for "terrorist purposes" after arriving in #Addis_Abeba from #Amhara region Addis Abeba: The Ethiopian Federal Police claimed its forces have “seized illegal weapons”, “intended for terrorist purposes” after the arms allegedly arrived in Addis Abeba “from the Amhara region.” In a statement, the Federal Police said the first seizure occurred at the Legetafo checkpoint, where officers “intercepted a vehicle”. Following what the federal police claimed as a “rigorous inspection,” authorities discovered “eight AK-47 assault rifles, 151 rounds of AK-47 ammunition, 17 rounds of Bren machine gun ammunition, and seven AK-47 magazines concealed inside the vehicle.” “The illegal weapons were being transported for terrorist purposes,” the Federal Police said, adding that the suspects were “detained at the scene.” https://x.com/addisstandard/status/2037186920086733010?s=20

123•••78
ПретходнаСтраница 1 од 8Следна