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

Резултати

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

Пребарај: #repo

当前筛选 #repo清除筛选
Repositorio data science

@repo_science · Post #3450 · 18.07.2023 г., 22:31

#Repo-PowerBI Cumpliendo las peticiones de algunos de ustedes hemos creado un 💫Nuevo grupo de PowerBI, donde estaremos compartiendo cursos, y libros. Pueden unirse en el enlace de abajo👇 🔗Link ----- Main channel:@repo_science Coupons:@freecoupons_reposcience -----

Hashtags

BotzHub

@botzhub · Post #378 · 25.02.2026 г., 16:04

Reaction Saver #repo: https://github.com/xditya/ReactionSaver - React to any message in DMs to save to your configurable LOG_CHAT - Good for messages or files sent in DMs with privacy enabled (forwards turned off) - Steps to set up are available here Star the repo if it helped :) ~ @BotzHub

Hashtags

BotzHub

@botzhub · Post #377 · 02.02.2026 г., 14:22

🎉 Just pushed a new repository to GitHub, been a while :) ImageTools #repo: https://github.com/xditya/ImageTools a python script to manipulate images - Resize images to exact pixel dimensions (width × height) - Auto compress images to target file sizes with optimal quality. - Add noise to ensure the image size meets your requirements. - Works with JPEG, PNG, and WebP formats. Makes applying for online examinations easier - no more visiting random websites to alter image dimensions and sizes! Do leave a ⭐️ if the repo helped :) ~ @BotzHub

Hashtags

BotzHub

@botzhub · Post #314 · 25.01.2024 г., 15:44

Presenting @GeminiTalkBot! Yes, that's me releasing a bot after a long time lol #repohttps://github.com/xditya/GeminiChatBot (do give a 🌟) An AI ChatBot and problem solver, using Google's Gemini AI Model. - remembers conversations for a smoother problem solving experience, without leaving telegram! - utilizes Gemini's full capabilities in text generation. - and more, idk what to add here 🙂 Follow me on GitHub & help me reach 500 followers! https://github.com/xditya ~ @BotzHub

Hashtags

BotzHub

@botzhub · Post #277 · 08.08.2023 г., 16:32

WhatsApp Media to Sticker #repo - https://github.com/xditya/WhatsAppUtilitiesBot (do give a ⭐) - A WhatsApp userbot, currently aimed at converting media to stickers, from within WhatsApp! You can find a sample bot in the comments of this post, but I'd recommend hosting one yourself, to prevent bans! Let me know if you have ideas to implement in this bot 😄 Heavily inspired by J Projects ~ @BotzHub

Hashtags

BotzHub

@botzhub · Post #276 · 02.08.2023 г., 04:42

😇 Just made a link shortener website, https://short.xditya.me 🔥 It's opensource, #repo: https://github.com/xditya/WebShortener(do give a ⭐️) and has an API endpoint! 🌚 Powered by 👩‍💻 👀 Please give your feedback, this is my first working website ~ @BotzHub

Hashtags

BotzHub

@botzhub · Post #268 · 07.06.2023 г., 15:26

🆕PresentingGetRestrictedMessages! ✈️ Deploy your own userbot to copy messages from public and private telegram chats with forward restrictions enabled! 🔥#repo - https://github.com/xditya/GetRestrictedMessages React to this message with "🌚" if you want a video tutorial on deploying it! 😎 Let me know your opinions in the comments! Star the repository, it encourages me to make more open-source projects :) ~ @BotzHub

Hashtags

BotzHub

@botzhub · Post #243 · 22.12.2022 г., 02:12

Presenting @TGdetailsBot #repo - https://github.com/xditya/TGdetailsBot - Get the message data in a telegram message. - Get chat ID, or forwarded from (channel/user) ID. - "Interactive" bot. - Supports clones (read "help" of the bot to know more)! ~ @BotzHub

Hashtags

BotzHub

@botzhub · Post #236 · 03.11.2022 г., 17:45

Deployyour own version of@ChannelActionsBot! Tutorial - https://youtu.be/hjxfJtk5ZWs #repo - https://github.com/xditya/ChannelActionsBot Like the video! ~ @BotzHub

Hashtags

BotzHub

@botzhub · Post #224 · 15.09.2022 г., 05:06

@PexelsSearchBot #repo🌐 - https://github.com/xditya/PexelsBot - Inline bot to search images from Pexels. - Open-source, made in ts 👌 - Use the bot inline, to search and send high quality images from pexels.com. ~ @BotzHub

Hashtags

BotzHub

@botzhub · Post #218 · 24.08.2022 г., 16:56

@MDiskLinksRoBot 🌐#repo - https://github.com/xditya/mdiskDownloadLinks - Generate direct download links from any MDisk.me link. - My first bot in TS 👩‍🦯 - Please do 🌟 the repository! ~ @BotzHub

Hashtags

BotzHub

@botzhub · Post #213 · 31.07.2022 г., 15:24

@TheEmailBot 🌐#repo - https://github.com/xditya/Mailbot - Generate temporary emails from within telegram. - Receive mails in that temp mail directly in the bot, with attachments, if any. - @TheEmailBot also supports custom as well as random email addresses. Do star the repository⭐️ Also, thanks for 12k members in this channel! ❤️ ~ @BotzHub

Hashtags

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