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

Резултати

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

Пребарај: #jio

当前筛选 #jio清除筛选

#人物 other (单个表情包放这) 国王排名 波吉 https://t.me/addstickers/king_ranking 小蓝和他的朋友们 https://t.me/addstickers/WeChat_LittleBlueAndHisFriends https://t.me/addstickers/XiaolanGif watora 和 potofu https://t.me/addstickers/watora_potofu Urara迷路帖 #video https://t.me/addstickers/urara_by_favorite_stickers_bot 加零 https://t.me/addstickers/jia0_hd 樱田诗露 桜田シロ https://t.me/addstickers/Sakurada_Shiro 义眼 丁真 https://t.me/addstickers/TenzingTsondu https://t.me/addstickers/tenzing https://t.me/addstickers/tenzing_plus https://t.me/addstickers/dingzhen_universe_by_luxiaoxun_bot https://t.me/addstickers/tenzing_mega 坤坤 鲲鲲 ikun 小黑子 https://t.me/addstickers/ikunsticker_666_by_luxiaoxun_bot https://t.me/addstickers/ikunsticker2_666_by_luxiaoxun_bot https://t.me/addstickers/wmikun https://t.me/addstickers/ikundongtu 爬 原作:蜜汁工坊 https://t.me/addstickers/GeiWoPa 美食广场里的女高中生在说啥 https://t.me/addstickers/msgcldngzszss 大时代 https://t.me/addstickers/greedtime https://t.me/addstickers/TheGreedOfManVideo#video FX战士久留美 韭留美 https://t.me/addstickers/FXSENSHI 超天酱 主播女孩重度依赖 https://t.me/addstickers/chaotianjiang https://t.me/addstickers/overdose228_by_fStikBot Liyuu https://t.me/addstickers/liyu0109 https://t.me/addstickers/liyu01092 雪糕糕 #jio https://t.me/addstickers/tsubasachyan https://t.me/addstickers/baisixuegaogao FGO https://t.me/addstickers/fgo2chibiii https://t.me/addstickers/fgoservant bilibili B站 22娘 33娘 https://t.me/addstickers/bili2233 崩坏3 https://t.me/addstickers/honkai_sticker https://t.me/addstickers/Teriri_Pack https://t.me/addstickers/Elysia_bh3 Ryukko https://t.me/addstickers/VR_Chat Kero https://t.me/addstickers/Kero_VR noy娘 https://t.me/addstickers/noygirl Lakr233 https://t.me/addstickers/Lakr233_0 软糖酱 https://t.me/addstickers/lxbot https://t.me/addstickers/missedtank helltaker https://t.me/addstickers/heltek666 梦璃 星梦璃月 https://t.me/addstickers/ritsuki 毒霸姬 https://t.me/addstickers/xiaodubaji https://t.me/addstickers/KingsoftKISGirl minahoshi https://t.me/addstickers/XxyujiVsMinahoshiChan 魔法少女小圆 https://t.me/addstickers/Akemi_Homura FX战士久留美 https://t.me/addstickers/FXSENSHI

🦅 [ perspective ix ]

@perspectiveix · Post #1990 · 04.05.2020 г., 17:00

Tech, Media, and Business News Headlines—Day 3 👉#Intel is in talks to acquire #Moovit for ~$1B (link) 👉#Uber to require masks or face coverings for drivers and passengers in certain markets (link) 👉 Security lapse at #India’s #Jio exposed #coronavirus symptom checker results (link) 👉#Amazon, #Flipkart, #Ola and #Uber begin to resume their services in #India (link) 👉#UberEats exits seven markets (link) 👉 The 13-inch #MacBook Pro gets #Apple’s much-improved keyboard (link) 👉 Poynter Institute’s International Fact-Checking Network launches chatbot on #WhatsApp to debunk thousands of #coronavirus-related hoaxes (link) 📰@iXDaily by @PerspectiveIX 💌Weekly Newsletter.

Desi Memes Funny Jokes

@desi_memes_funny_jokes · Post #4983 · 10.07.2024 г., 03:47

Paisa hai to kya kuch nahi ho sakta🤣 #matstudios#sochobolopao#indianmemes#indianfunny#bhagambhag#justinbieber#mukeshambani#bollywoodcomedy#bollywoodedits#bollywoodmemes#ambani#ambaniwedding#jio