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

Резултати

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

Пребарај: #aichatbot

当前筛选 #aichatbot清除筛选
Daily Channels

@dailychannels · Post #6774 · 26.03.2026 г., 13:00

Group: ZombieSquad Community Members: ~14.09K 💢 Username: @zombiesquadhq Description: 🔥 Come play the game and earn sunlight, with a chance to score some airdrop rewards! 🏷 Tags: #airdrop #cryptocurrencies#aichatbot#airdrop#crypto https://lve.to/k1gt8zxptq

#脚本#QuantumultX#Loon#Surge#Shadowrocket#Stash#Crack#adapty#效率#AI ✅#AiChatbot 📱 更新版本: 1.39 👤 脚本作者: @ddm1023 🕒 更新日期: 2024-11-09 📌 脚本功能: 解锁Pro 💳 特别说明: 非一次性解锁,先开启规则,在进入软件即可!如果无效按[恢复购买]进行恢复! ⬇️ 下载地址: 点击下载 🔗 脚本链接: 长按复制 ➡️ 一键导入: 点击导入 🔄 脚本转换: 点击传送 ✈️导航💬群组🤖投稿🎁福利

Nicegram

@nicegramapp · Post #306 · 26.03.2023 г., 15:10

🌟 Discover Twin GPT - The Cutting-Edge AI Communication on Nicegram! 🌟 Exciting news for Nicegram users! The Nicegram team is proud to reveal that the long-anticipated NGC token will power the innovative Twin GPT platform! Twin GPT is a revolutionary user-owned AI chatbot seamlessly integrated with Nicegram Messenger. Create, customize, and engage in limitless conversations with your AI Twin, all while unlocking extraordinary communication and monetization opportunities using our NGC token ecosystem. 🚀 Are you ready to dive into the world of NGC and Twin GPT on Nicegram? 🔥 Join the Twin GPT Discussion Group to ask questions, share experiences, and connect with other enthusiasts, particularly those intrigued by NGC and Nicegram:Click here to join the discussion group Keep an eye out for the latest news, updates, and events on Twin GPT and NGC, right here on Nicegram! #TwinGPT#AIChatbot#NGC

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