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

Резултати

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

Пребарај: #sans

当前筛选 #sans清除筛选
Pensive|

@PensivePost · Post #5527 · 26.11.2021 г., 07:23

How to not hold on to the belongings Whilst you bathe in the agony and I am out there revolting We see the stars with tears in our eyes and we know there's no dream left But we do still be hopelessly waiting for the hope in disguise There's so much patience in us but we no more could put up with the dread in our minds Halfway through the day we yet keep awaiting for the nights We have gotten nowhere but look how far have come our lives From finding the purpose of our souls to now laying down helplessly with inconsequential smiles Only you and I know how to convey the inconveniency of the bothersome hearts with APHASIA Expressing themselves with insufficient words and futile rhymes #review #sans

Hashtags

Pensive|

@PensivePost · Post #5372 · 23.08.2021 г., 18:34

For courage is letting go of the fears that you reside in and hope of a being Gasp until your heart aches for the warmth of the love it once shared Bawl to the agony of tragedy that flowed along with the blood through your veins Fall into the symphony Edvard Grieg once made Reach to the point of disgust and bathe in the trauma that surrendered to you its faith Exist in seventeen out of hundred of your fears For once, look closer into the mirror that is as real as it appears Leer at The Starry Night, no Vincent could ever paint Until your eyelids close to their suspense Oath to the pores that your skin ever veiled Behold the scars of your mother that never healed Go slow in the heads of horror Go deep in the dark philosophy in Arthur Schopenhauer’s honor Plead to the lord of misery, for great sufferings of ever beyond and more Wear the wisdom of the evil that history never wore And then, Let shadows of your beloved that long ago were burnt, sing you the last lullaby Sleep to never wake up again in the dream of demons, ode them the last goodbye Gather fragments of the courage you swore upon midst the million sufferings Open the doors once latched, let bright of your brain lit the horizon of infinite dreams #sans #review

Hashtags

Pensive|

@PensivePost · Post #4876 · 05.02.2021 г., 17:51

We have fought a battle, a long long ago. We might have won, but in pale yellow burnt scripts, there isn't any Trace, Though we believe, we utterly, dearly keep Faith In it's victory, and for it did win for our fate. I remember them saying, 'Through it's virtue God brought us Morals. And to continue we shall act upon our deeds, correct what one feels.' Never really did they emphasized on Ethics, As in pale yellow burnt scripts they might have found some invisible trace's of ink. And it might have said to them, ' Through what you believe, comes enactment of your deed, here's a path, don't bend,walk straight, here are rules, don't break, walk straight' And onwards and ahead, With God's sheer-sheer Grace, we Shall keep moving. As it says For them, Their God, Is pale yellow scripts. For me Mine somewhere else exists And when from afar afar, I ask him to take me away, He then silently maybe replies, In pale yellow burns, you carve me And then, just then, To you ,in their invisible Traces, might seem my smiles Until then, Believe them. Walk straight, don't bend, Here is your path keep on the chase. #review #sans #poetry

Pensive|

@PensivePost · Post #4848 · 31.01.2021 г., 14:52

We pave our way towards the stardust, When million collisions fade beside Our labour but a mere phenomenon to harbour where the bondsmen reside With weapons in our brain and shield in the sleeves When least of the mankind Shrink upon our feets We then in chorus sing our defeat, with cold in the blood till , we March towards the heat and Then on the arid land When we lay down the dead bones It rains through our sullen sights to the point we drown into our own build heights We then again Pave our way towards the stardust When million collisions fade beside When million collisions fade beside #review #poetry #sans

Pensive|

@PensivePost · Post #4840 · 29.01.2021 г., 10:58

We pave our way towards the stardust, When million collisions fade beside Our labour but a mere phenomenon to harbour where the bondsmen reside With weapons in our brain and shield in the sleeves When least of the mankind Shrink upon our weak feets We then in chorus sing our defeat, with cold in the blood till We March towards the heat and Then on the arid land When we lay down the dead bones It rains through our sullen sights to the point we drown into our own built heights We then again Pave our way towards the stardust When million collisions fade beside When million collisions fade beside #poetry #review #sans

科技&趣闻&杂记

@kejiqu · Post #3887 · 17.11.2025 г., 23:03

谷歌开源 Google Sans Flex 字体,可用于商业用途 谷歌已开源 Google Sans Flex 字体,用户可在 Google Fonts 平台免费下载使用,包括商业用途。该字体拥有 9 种变种,涵盖 Thin 100-Black 900 粗细范围,允许更改字重、宽度、粗细、光学大小和笔画圆角等参数。字体支持英语、法语、德语等多种拉丁语形式,但不含中文。Google Sans Flex 字体采用 SIL Open Font License 1.1 标准开源,允许免费使用、研究、修改和重新分发。IT之家 🏷#Google#Sans#Flex#开源#字体 📢 频道 👥 群组 📝 投稿

VIP_影视分享

@wangzhuanzhan · Post #33606 · 01.10.2024 г., 06:45

B-b悲b情q三s角j- 悲情三角 Triangle of Sadness (2022) 直达链接:https://pan.quark.cn/s/d4174b414dd0 #悲情三角#Triangle of Sadness #无限悲情#疯狂富作用 #上流落水狗#悲痛三角 #悲伤三角#悲哀三角#Sans filtre 链接:https://link3.cc/sf_com #电影#喜剧#美国#2022年代

Yukiokhruner

@yukiokhruner · Post #42 · 16.05.2022 г., 17:10

Alla ricerca di un qui ed un ora dalla forma conveniente per quanto ridotta all'osso. #vaporonda#vaporwave#vapourwave#vaporart#seapunk#webpunk#glitch#glitchart#glitchartistscollective#chillwave#aesthetic#vaporwaveaesthetic#vaporwaveaesthetics#malinconia#melancholy#tristezza#sadness#sadboy#lofi#testaccio#mattatoio#videogioco#videogame#undertale#undertalesans#sans