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

Резултати

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

Пребарај: #letthemsail

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

@FFC_official_channel · Post #225 · 04.09.2024 г., 20:53

BREAKING ⚠️🚨 ⛴️⛴️⛴️ After months of failed negotiations, the @gazafreedomflotilla campaign in Turkiye @mavimarmaratr started the #FreedomWatch , a non-violent direct action with hundreds of people to free our boats from Hyadarpasa port in Istambul. The demonstrators blocked the port entrance and peacefully chained themselves to the gates. 🚨 LIVE NOW: https://www.instagram.com/mavimarmaratr?igsh=emNib2ZtZHFjZTFj 🇵🇸🍉 The objective of this inspiring action is that the we can finally sail to #Gaza to take desperately needed humanitarian aid and break the genocidal siege that Israel established on Gaza since 2007. ⛴️ Our protests in Turkiye will continue until our boats are free to sail, since they have all the necessary documentation and meet all the necessary requirements to do so. Please help us share this important action to #BreakTheSiege and to create a people´s humanitarian corridor in Gaza. When governments fail, we sail! #FreedomFlotilla#WeWillSail#LetThemSail🇵🇸

Freedom Flotilla Coalition

@FFC_official_channel · Post #121 · 25.05.2024 г., 19:52

After prolonged negotiations with the Dutch Port Authority, ‘Handala’ is finally docked in Rotterdam! The Freedom Flotilla Coalition had organized a place to dock with Rotterdan City Marina but for undisclosed reasons, were prevented from docking in the planned location. This delay impacted our peaceful event and demonstration to welcome ‘Handala’ where children had drawn pictures and letters of support to send to Palestinian people in Gaza. John Turnbull, representative of Canada Boat to Gaza, said “while engaging on this mission, the Palestinians are teaching us how to resist”. Handala will continue to challenge the complicity of European countries on a journey to break the siege of Gaza. Next stop, London! #breakthesiege#endtheblockade#gaza#palestine#freegaza#freepalestine#weaillsail#letthemsail#handala

Freedom Flotilla Coalition

@FFC_official_channel · Post #197 · 25.07.2024 г., 07:59

Robert has long fought alongside Palestinians and isn't stopping now. Having spent time in Palestine documenting horrific human rights abuses by Israeli forces, he has seen the brutality of the occupation first hand. Despite the extreme difficulty in leaving his children and partner back home in what he describes as a "grieving process", he shares how important it is to use his privilege to be a part of the collective effort to break the siege on Gaza. As we have witnessed over the course of 9 months and 76+ years prior, we cannot fathom or predict the IOF's brutality or what they are capable of if they intercept 'Handala' in international waters. So we need your help in keeping Robert as safe as possible. We need your help in demanding safe passage for all volunteers onboard our Flotillas. Please share our videos, tag your politicians and ensure that we reach Gaza safely. #endtheblockade#breakthesiege#robertmartin#freepalestine#freegaza#endtheoccupation#solidarity#wewillsail#letthemsail

Freedom Flotilla Coalition

@FFC_official_channel · Post #102 · 12.05.2024 г., 07:10

Palestinians in Gaza are being forced to endure a “vicious cycle of malnutrition, infection, wounds breaking down, more infection, more malnutrition”, explains British surgeon haunted by Gaza horrors. Professor Nick Maynard has only just arrived back in the UK after lending his expertise in Gaza where he witnessed teenagers with treatable, survivable injuries, whose bodies tragically shut down due to malnutrition. We need to break the siege of Gaza. We need to ensure the borders are opened to be able to provide medical aid and food to these teenagers and their families immediately. This could not be more urgent. #BreakTheSiege#AllEyesOnRafah#EndTheBlockade#GazaBlockade#FreedomFlotilla#WeWillSail#LetThemSail#Rafah#NickMaynard

Freedom Flotilla Coalition

@FFC_official_channel · Post #226 · 06.09.2024 г., 04:19

The demonstration to release our Flotilla ships currently being prevented from leaving port by the Turkish Port Authorities, continues in Istanbul. We need your help in getting international media to cover this historic protest and help put pressure on the government to release our ships, ensuring we can sail towards Gaza. HOW TO HELP: 1. Call, email and/or demonstrate at Turkish embassies and consulates and demand that the Freedom Flotilla ships be released and allowed to deliver aid to Gaza immediately. 2. Tag mainstream accounts in this post or when you share our photos to your stories. 3. Message the social media page of the Ministry of Transport and Foreign Affairs @tcdisisleri and @uabakanligi on IG and on X 4. Share our videos using the hashtags #WeWillSail and #LetThemSail tagging @tcdisisleri and @uabakanligi #WeWillSail#LetThemSail#TheFreedomFlotilla#FFC#Istanbul#Turkiye#Turkey#MaviMarmara