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

Пребарај: #freedomflotillacoalition

当前筛选 #freedomflotillacoalition清除筛选
El Pueblo Informa

@EPInforma · Post #35479 · 09.06.2025 г., 02:03

Rumbo a Gaza 🇵🇸 | 12 voluntarios de todo el mundo que navegan en el #Madleen. Una misión para romper el asedio ilegal de Israel a Gaza y establecer un corredor marítimo popular. #FreedomFlotillaCoalition Vía 📱@PiensaPrensa Síguenos t.me/Epinforma🔁 comparte

Freedom Flotilla Coalition

@FFC_official_channel · Post #64 · 02.05.2024 г., 20:52

‘Handala’ has just left Oslo and is on its way to various European ports before heading to Gaza. “‘It feels important to be able to participate in a manifestation that draws people’s attention to Israel’s genocide in Gaza”, said Stefan. Sundström is among the human rights activists and artists traveling on or meeting Handala, such as the group Nynningen, General Knas, and Karin xx, who will perform at several ports and finally in Malmö, where Eurovision is taking place. Both artists Mikael Wiehe and Daniel Lemma will be present at the reception.” Head to our website for the full press release, and follow @shiptogazanorway and @ship_togazasweden for live updates. #BreakTheSiege#Handala#FreedomFlotillaCoalition#Norway#FreeGaza#FreePalestine#WeWillSail

Freedom Flotilla Coalition

@FFC_official_channel · Post #769 · 12.09.2025 г., 11:35

@freedomflotillacoalition and @thousandmadleenstogaza are joining forces as one flotilla to challenge Israel’s illegal and inhumane blockade of Gaza. Our shared mission is rooted in solidarity and justice, standing with the Palestinian people in their struggle for freedom. Like every past mission, this flotilla is a civil intervention against Israel’s 18-year long illegal blockade on Gaza—which has now been used to manufacture a famine—and a demand for accountability. We sail because governments and corporations remain complicit in Israel’s occupation, apartheid, and genocide. All eyes on Palestine 🇵🇸 #freegaza#freepalestine#alleyesongaza#alleyesonpalestine#endtheblockade#freedomflotillacoalition#FFC#thousandmadleenstogaza

Freedom Flotilla Coalition

@FFC_official_channel · Post #215 · 19.08.2024 г., 21:03

Our objectives—to break the blockade and raise awareness of the genocide against Palestinians in Gaza—remain unchanged. We will provide updates on our next departure when we are ready to sail again. In the meantime, we urge you to join the #NoHarbourForGenocide campaign to take action against the siege on Gaza by opposing every country and company complicit in this genocide. #handala#ffc#freedomflotillacoalition#freegaza#freepalestine#endtheoccupation#breakthesiege#endtheblockade#iof#warcrimes#icc#icj