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

Резултати

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

Пребарај: #telegramthursday

当前筛选 #telegramthursday清除筛选

It's 'Telegram Thursday' and I want to recommend interesting channels. Today I was recommended a pretty fine channel, which focuses on Paganism: https://t.me/s/pagan_revivalism @Pagan_Revivalism Check it out and share if you like the content! The second channel I enjoy to check out every now and then is this one: https://t.me/s/folkwisdom @folkwisdom Pretty interesting forwards sometimes, from accelerationism to white pills. #TelegramThursday @EuropeanTribalism

It's 'Telegram Thursday' and I want to recommend interesting channels. Today I want to point out a channel dedicated to Germanic topics with lots of own content: https://t.me/s/oakwhispers @oakwhispers Give the creator a chance and check it out! It's important that we have channels like this, which add own content instead of plain forwarding. #TelegramThursday @EuropeanTribalism

It is 'Telegram Thursday' and I want to recommend you interesting channels. Today I would like to recommend a couple of channels I regularly read. No, not just content skipping, but actually reflecting on the content: https://t.me/tribeofthefox https://t.me/GreekLeague https://t.me/folkwisdom https://t.me/skogarvordurinn Go ahead and check them out! #TelegramThursday @EuropeanTribalism

It is 'Telegram Thursday' and I want to recommend you interesting channels. Today I would like to point out the channel from a lad I know from the time I was still on Twitter: https://t.me/AureusPress There is art, neo-futurism and quite some gems to be found on this channel. So go and check it! #TelegramThursday @EuropeanTribalism

I am not sure if everybody is aware that you can access all Telegram channels without having Telegram installed. You want to visit your favourite channel @EuropeanTribalism over your web browser? Try this: https://t.me/s/EuropeanTribalism You want to share the fantastic articles from @solarcult? Try this: https://t.me/s/solarcult Want to read one of @morrigancarrick's memes? Just add a number, which is the article ID at the end. Try this: https://t.me/s/morrigancarrick/533 Share it with your Telegram-free friends! #TelegramThursday @EuropeanTribalism

It's 'Telegram Thursday' and I want to recommend you some interesting channels: @PrimordialPath - a very interesting channel with straightforward opinions and views. If you are into Folk Futurism, go and check it out! @Solarcult - a channel devoted to mythology, history and Aryan heritage. Definetly worth a follow. @VolkischShakti - this channel focuses on information about female deities. If you are into mythology, it's worth to read it. Be sure to share quality content when you find it! #TelegramThursday @EuropeanTribalism

It is 'Telegram Thursday' and I want to recommend you some interesting channels: @philosophicat, who also runs a youtube channel by this name, adds a very unique perspective to current happenings. Also check out her series on Evolas 'Revolt Against the Modern World'! @aryologia has lots of interesting content if you are interested in Indo-Aryan culture. @mythologicalfact focuses on Vedic content. If you want to extend your knowledge about ancient myths, be sure to give them a follow. @getthispdf is my channel for collecting interesting eBooks for the topics physics, spirituality and history. If you want a good read, check it out. Be sure to share quality content when you encounter it! #TelegramThursday @EuropeanTribalism

It's 'Telegram Thursday' and I want to recommend you interesting channels. Today marks the first of a series of recommendations, based on the various expressions of European culture. We start with a channel, which focuses on the Slavic aspect: https://t.me/THEOLDWAYS Have a look and follow! #Slavic#TelegramThursday @EuropeanTribalism

12
ПретходнаСтраница 1 од 2Следна