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

Пребарај: #iof

当前筛选 #iof清除筛选
Freedom Flotilla Coalition

@FFC_official_channel · Post #525 · 10.06.2025 г., 18:49

Some snippets from Greta’s interview after being deported by Israeli authorities. Continue fighting for Palestinians in Gaza, including those in wider Palestine who are unlawfully imprisoned, including over 400 children. #Madleen#IOF#GretaThunberg#FreedomFlotilla

Freedom Flotilla Coalition

@FFC_official_channel · Post #538 · 11.06.2025 г., 20:39

Lara, speaking from Brazil, has had no contact with her husband, Thiago Ávila, since he was abducted and detained illegally by Israeli forces from the 'Madleen'. Since then, Thiago has been placed in solitary confinement, denied communication with his family. According to Lara, Israeli authorities threatened Thiago with the psychological torment of isolation without light or ventilation. Despite this, Thiago remains on hunger strike, holding firm to his belief in justice for Palestinians and the right of every child to food, safety, and freedom. From his prison cell, he wrote a letter to his 1-year-old daughter. Lara generously shares that with us today. This is a call not just for Thiago’s release—but for the world to pay attention to Gaza, to Palestine, and to all people who are exploited, forced to live under occupation. #FreedomFlotilla#Madleen#Thiago#IOF#WeWillSail#BreakIsraelsSiege#EndTheBlockade

Freedom Flotilla Coalition

@FFC_official_channel · Post #502 · 09.06.2025 г., 12:06

Freedom Flotilla Official Update: It's time for our governments to do their jobs and sanction Israel. Its illegal attack on 'Madleen' while sailing in international waters is a small extension of their war crimes in Gaza. Governments, institutions, media, and corporations must stop protecting Israel, now. They must stop prioritising profit over human lives, now. Protect our volunteers while protecting Palestinians in Gaza and wider Palestine. #BreakIsraelsSiege#EndTheBlockade#Madleen#FreedomFlotilla#Volunteers#IOF#StandWithGaza#StandWithPalestine

Freedom Flotilla Official Update: It's time for our governments to do their jobs and sanction Israel. Its illegal attack on 'Madleen' while sailing in international waters is a small extension of their war crimes in Gaza. Governments, institutions, media, and corporations must stop protecting Israel, now. They must stop prioritising profit over human lives, now. Protect our volunteers while protecting Palestinians in Gaza and wider Palestine. #BreakIsraelsSiege#EndTheBlockade#Madleen#FreedomFlotilla#Volunteers#IOF#StandWithGaza#StandWithPalestine

Freedom Flotilla Coalition

@FFC_official_channel · Post #561 · 13.06.2025 г., 20:57

Yanis Mhamdi, from his prison cell: “If I had to do it all over again, I'd do exactly the same thing”. Illegally detained in Israel since the attack on the “Gaza Freedom Flotilla” in international waters, journalist Yanis Mhamdi sent us a letter, written from his prison cell, before news had reached him of a possible one month extension due to Israel's attacks on Iran. #BreakIsraelsSiege#EndTheBlockade#WeWillSail#IsraelIran#IOF#Madleen#FreedomFlotilla#RimaHassan#YanisMhamdi

Freedom Flotilla Coalition

@FFC_official_channel · Post #207 · 11.08.2024 г., 16:17

"Families of Gaza are not less important than my family. It’s by mere chance that we are not one of those families that are in Gaza right now." Thiago Ávila, father and activist aboard 'Handala', will sail towards Gaza with an urgent mission: to break the illegal siege and stand with the children of Gaza. 'Handala' is a small boat, but it carries the weight of a global uprising for justice. As catastrophic famine unfolds across Gaza, evidence of heinous sexual and physical violence by the IOF continues to emerge, and the Israeli and U.S.-backed genocide persists with impunity, people power is more integral than ever—it’s up to us to shape a new society. The world must not turn its eyes away. Keep your eyes on 'Handala'. Share our mission, amplify Palestinian voices, and do everything you can to stand for Gaza. The flood of change is coming—be part of it. #FreedomFlotilla#Handala#FreePalestine#Gaza#AllEyesOnDeck#FreeGaza#WeWillSail#Thiago#Brazil#HumanRights#Genocide#IOF

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