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

Резултати

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

Пребарај: #db

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

@PensivePost · Post #4940 · 18.02.2021 г., 18:48

BRUISED For if I told you that I love you Anywhere but in my poetry Coz I know my pen Would Slip Away And It would too Give you the power to walk away But no my dear So for now I will write For not manifesting my love And never for denying it I write implicit poetry Words inside me that I burry For I have mastered the art of concealing Through experience, the techniques of disguising Optical illusion overlaid on a lucid painting The sourness in my eye Veiled within a mimic smile Lips dyed in radiant color so they occur But a dull abstract as u look closer I trusted once revealing my secret But I ended up being its captive A mistake unlocked a new aspect And with silence I became adaptive A weightless body floating between time & space A glitch in a cosmos no gravity in my case Murky blood from a ruptured spleen A conversation in the dark with the monsters I’ve seen Haunted by the spoken but never meant A feign genesis from which I lack Kent Devils resembling a facsimile saint Words with their actions they never acquaint Took a lesson from the repeated voice To be stuck or to evolve is my choice Fading in the past or living in the present Cherishing the mistakes or frowning at the moment So here am writing With all I got embracing Inscribing my pain with the ink from my heart Palms bruised so I won’t fall apart To the scheme of world to the pit of lie I might be here but your deceits I won’t buy So to infect me with your diseases Please don’t try Over losing this attitude I would rather choose to die As an authentic bruised version of me Without a single manipulation there is to be So for now again I’ll let my fountain pen drain And spill its blood out On this half wrenched paper And scribble the words for no doubt And create an art ‘till the burning piece taper And pierce my heart And ache my head till its bursts And till my lung stifle And my hands go weak And my eyes drench And my ears bleed And my nose drop And my paper withers… I will then drown out the wrapped Into the ashbin Until it soaks all the scrap And then ask for something That’s long gone into the dark iniquity But lasts in my soul till the eternity. #review#DB#poetry

#DB#百家乐 🛍 🛍 🤝 🤝 🛍 🏦 🛍 🛍 😄 😄 😄 😄 😄 😄 😄 DB真人-百家乐是一款广受欢迎的博彩游戏,每种博彩游戏都有其独特的规则,百家乐也不例外。在开始玩百家乐之前,了解并掌握其规则至关重要。通过熟悉规则,不仅可以避免亏损并提高胜率,还能更专注地享受赌博带来的乐趣与刺激。 🎁充值 😀 😝 😝 😝 😀 😄喜提 😀 😀 😀 😀 😀 😀 😄 😄 😄 😄 😄 😄 📱 官方客服:@LBKF66 📱 合营招商:@LBZS01 📱 官方频道:@leboPD 📱 福利交流群:@LBYLSVIP 🛍乐博娱乐 知名品牌 安全可靠 值得信赖 🛍加入乐博,爆奖、提款、到账,一气呵成!

OKHK 👀

@iokhk · Post #9511 · 22.04.2026 г., 06:01

pgmicro 是一个基于 Turso(Rust 编写的 SQLite 重构版本)的实验性项目,它通过解析 PostgreSQL 语法并将其直接编译为 SQLite 字节码,实现了 PostgreSQL 的进程内嵌入式运行,适合 AI Agent 使用。 https://github.com/glommer/pgmicro #DB#Tool#AI#GitHub

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