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

Резултати

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

Пребарај: #sadness

当前筛选 #sadness清除筛选
Quiet World 🍁

@QuietWorld · Post #6998 · 30.11.2019 г., 02:40

🍂 “Our Lord has written the promise of resurrection, not in books alone but in every leaf of springtime.” – Martin Luther 🌻look at the trees with fallen leaves during autumn, they keep on standing and stand strong despite many of their leaves fall down; as if they know and trust that they will not stay in that condition forever - in fact, they'll shine more beautifully soon when the spring comes. so dear, whenever you are in crestfallen, trust that that too shall pass.. be sad, but don't lose hope that tomorrow can be better☺️ #life#thoughts#sadness#happiness#motivation @quietworld🍃

Quiet World 🍁

@QuietWorld · Post #7015 · 01.12.2019 г., 08:31

🍂 something you dislike happened? you couldn't get something you wish for? you have been disappointed and someone hurt you? you lost someone? you failed at something you hope you're good at? and you feel sad about it? then be so. feel sad. be sad. cry if you must. cry your heart out. let it out. it heals to cry. it heals to allow yourself to feel things; be human. because yes it is difficult to go through those things. & that doesn't mean that you are weak. to feel those feelings are not a sign of weakness at all ; just that we are human, we are born with the ability to feel those emotions. your strength is not determined by your ability to suppress emotions, but by your ability to overcome it; by not letting it controls yourself longer than it should be. there's light at the end of the tunnel if you keep going. #thoughts#notetoself#selfreminder#strength#positivity#sadness#motivation @quietworld🍃

Yukiokhruner

@yukiokhruner · Post #25 · 15.04.2022 г., 19:21

L'amore ed i sentimenti in generale stanno vivendo una brutta epoca, sostituiti il più delle volte da pulsioni eremitiche. #vaporonda#vaporwave#vapourwave#vaporart#seapunk#webpunk#glitch#glitchart#glitchartistscollective#chillwave#aesthetic#vaporwaveaesthetic#vaporwaveaesthetics#malinconia#melancholy#tristezza#sadness#sadboy#lofi#illusione#illusion#solitudine#loneliness#luciajavorcekova

La guerra é portatrice di ingiustizie ed inganni, di questi ultimi uno dei più grandi é quello di pretendere di costruire un mondo migliore. #vaporonda#vaporwave#vapourwave#vaporart#seapunk#webpunk#glitch#glitchart#glitchartistscollective#chillwave#aesthetic#vaporwaveaesthetic#vaporwaveaesthetics#malinconia#melancholy#tristezza#sadness#sadboy#lofi#guerra#war#violenza#violence#illusione#illusion

Yukiokhruner

@yukiokhruner · Post #27 · 24.04.2022 г., 15:09

Non é entusiasmante prendere consapevolezza di essere quasi coetaneo di Homer Simpson. #vaporonda#vaporwave#vapourwave#vaporart#seapunk#webpunk#glitch#glitchart#glitchartistscollective#chillwave#aesthetic#vaporwaveaesthetic#vaporwaveaesthetics#malinconia#melancholy#tristezza#sadness#sadboy#lofi#simpson#simpsonwave#homer#homersimpson

Yukiokhruner

@yukiokhruner · Post #11 · 02.04.2022 г., 10:43

Secondo me a livello culturale siamo immersi in una sorta di nuovo barocco, nell'accezione più deteriore del termine. #vaporonda#vaporwave#vapourwave#vaporart#seapunk#webpunk#glitch#glitchart#glitchartistscollective#chillwave#aesthetic#vaporwaveaesthetic#vaporwaveaesthetics#malinconia#melancholy#tristezza#sadness#sadboy#lofi#apparenza#appearance#illusione#illusion#spettacolo#show

Yukiokhruner

@yukiokhruner · Post #48 · 09.06.2022 г., 15:40

Mi sono stancato di influencer e tiktoker vari, buoni solo a pietrificare l'attenzione verso cose futili. #vaporonda#vaporwave#vapourwave#vaporart#seapunk#webpunk#glitch#glitchart#glitchartistscollective#chillwave#aesthetic#vaporwaveaesthetic#vaporwaveaesthetics#malinconia#melancholy#tristezza#sadness#sadboy#lofi#apparenza#appearance#appearance#illusione#illusion#incubo#nightmare

#vaporonda#vaporwave#vapourwave#vaporart#seapunk#webpunk#glitch#glitchart#glitchartistscollective#chillwave#aesthetic#vaporwaveaesthetic#vaporwaveaesthetics#malinconia#melancholy#tristezza#sadness#sadboy#lofi#guerra#violenza#violence#futurismo#futurism#willsmith

Yukiokhruner

@yukiokhruner · Post #46 · 04.06.2022 г., 15:03

Parole inconsistenti e pii desideri. #vaporonda#vaporwave#vapourwave#vaporart#seapunk#webpunk#glitch#glitchart#glitchartistscollective#chillwave#aesthetic#vaporwaveaesthetic#vaporwaveaesthetics#malinconia#melancholy#tristezza#sadness#sadboy#lofi#illusione#illusion#utopia#razzismo#racism#cgil

Yukiokhruner

@yukiokhruner · Post #13 · 03.04.2022 г., 15:18

Trovare le parole giuste con tutti e saper cogliere le sfumature di tutte quelle che ricevo, l'ho sempre trovato uno sforzo estremo. #vaporonda#vaporwave#vapourwave#vaporart#seapunk#webpunk#glitch#glitchart#glitchartistscollective#chillwave#aesthetic#vaporwaveaesthetic#vaporwaveaesthetics#malinconia#melancholy#tristezza#sadness#sadboy#lofi#disagio#unease#comunicazione#communication#linguaggio#language

Yukiokhruner

@yukiokhruner · Post #15 · 05.04.2022 г., 16:16

L'attaccamento agli oggetti é uno degli ostacoli maggiori per la nostra felicità, come se infondessimo in essi parte della nostra anima. #vaporonda#vaporwave#vapourwave#vaporart#seapunk#webpunk#glitch#glitchart#glitchartistscollective#chillwave#aesthetic#vaporwaveaesthetic#vaporwaveaesthetics#malinconia#melancholy#tristezza#sadness#sadboy#lofi#disagio#nostalgia#illusione#illusion#windows95#windows98#windowsxp

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