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

Пребарај: #safepassage

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

@FFC_official_channel · Post #373 · 03.06.2025 г., 03:11

UN EXPERTS DEMAND SAFE PASSAGE FOR ‘MADLEEN’ JOIN THEM Today, UN experts called for safe passage for the Madleen — our civilian ship carrying vital aid and international volunteers to Gaza. Now we need your voice. Let’s turn international law into action. 📣 Take one minute: go to bit.ly/IsraelOnNotice and send a letter to the Israeli government, UN officials, and diplomatic missions demanding that Israel abide by international law and refrain from attacking, sabotaging or otherwise interfering with the Madleen and her mission. Together, we can open a people’s sea corridor to Gaza. #SafePassage#BreakTheSiege#FreedomFlotilla

Freedom Flotilla Coalition

@FFC_official_channel · Post #671 · 23.07.2025 г., 20:23

Six of the seven U.S. citizens aboard the Freedom Flotilla’s ‘Handala’ just read a powerful open letter to Donald Trump and the U.S. government. From the founder of Amazon Labor Union’s to a U.S. war veteran, a lawyer, a marine rescue worker, a human rights attorney, and an actor—each one delivered a searing truth: the U.S. is an active participant in Israel’s war crimes against Palestinian children in Gaza. If the U.S. does not support the deliberate starvation of children, they should guarantee safe passage of ‘Handala’. ‘Handala’ plans to deliver food, medicine, and baby formula to Gaza in a few days. They are unarmed, trained in nonviolence, and yet, are under threat by Israel. If anything happens to them, the world will know who is responsible. Share this. Tag your politicians. Break the silence. Let the world see who’s standing on the right side of history. #PresidentTrump#Handala#SafePassage#FreedomFlotilla#ForTheChildrenOfGaza#StandWithGaza#AllEyesOnDeck

Freedom Flotilla Coalition

@FFC_official_channel · Post #452 · 06.06.2025 г., 22:46

🚨 ACTION ALERT: The UK MUST protect ‘Madleen’ 🚨 The ‘Madleen’ is a UK-flagged civilian ship sailing to Gaza with life-saving aid as part of the #FreedomFlotilla. The UK has a legal duty to protect its vessel and the civilians aboard from Israeli interference. 🇬🇧 Under international law, the UK must: • Prevent genocide • Reject Israel’s illegal blockade of Gaza • Defend its flagged ship from unlawful attacks Support us by taking action! Contact the Foreign Office and your MP. Demand protection for the ‘Madleen’ and accountability for any aggression. Email: [email protected] X: @FCDOGovUK IG: @ForeignAndDevelopmentOffice Tel: 020 7008 5000 #SafePassage#UKResponsibility#BreakTheSiege#BreakIsraelsSiege#EndComplicity#Madleen#GazaGenocide#FreedomFlotilla

Crypto M - Crypto News

@CryptoM · Post #64921 · 10.04.2026 г., 09:34

🚀 Malaysian Prime Minister Confirms Safe Passage of Oil Tankers Through Hormuz Strait On April 10, Malaysian Prime Minister Anwar confirmed that six out of seven oil tankers heading to Malaysia have successfully navigated the Hormuz Strait. According to BlockBeats, the remaining vessel is currently undergoing repairs due to mechanical issues and remains docked at the port. #MalaysianPrimeMinister#OilTankers#HormuzStrait#SafePassage#Anwar#MechanicalIssues#BlockBeats#Malaysia