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

Резултати

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

Пребарај: #neovim

当前筛选 #neovim清除筛选
GitHub Trends

@githubtrending · Post #15553 · 10.03.2026 г., 12:00

#lua#github#neovim Octo.nvim lets you edit and review GitHub issues, pull requests, and discussions right in Neovim. Just open with commands like `//github.com/user/repo/issues/1` or `w` to sync changes instantly. Add reactions, labels, assignees, or reviewers easily. This saves time by keeping all GitHub work in your editor—no browser switching—boosting productivity for developers managing repos. https://github.com/pwntester/octo.nvim

GitHub Trends

@githubtrending · Post #15599 · 03.04.2026 г., 11:30

#rust#filesearch#lua#neovim#neovim_plugin#rust FFF is a super-fast fuzzy file finder for AI agents and Neovim users. It excels at grepping, fuzzy matching, and globbing with built-in memory that ranks results by frecency, git status, file size, and more for typo-proof searches. Install easily via script for AI (like Claude) or Lua for Neovim (keys like ff for files, fg for grep). This saves you time and tokens by finding code instantly, skipping useless files, and boosting productivity on big repos. https://github.com/dmtrKovalenko/fff.nvim

GitHub Trends

@githubtrending · Post #14753 · 26.05.2025 г., 12:00

#tree_sitter_query#hacktoberfest#neovim#nvim_treesitter#tree_sitter Nvim-treesitter is a plugin for Neovim that makes it easy to use Tree-sitter, a modern parsing tool, for better syntax highlighting and code understanding in your editor[1][2]. It automatically installs and manages language parsers, so you don’t have to do it manually, and supports many programming languages out of the box. With nvim-treesitter, you get more accurate and faster syntax highlighting, smarter code navigation, and features like incremental selection, indentation, and code folding, all based on the actual structure of your code[4]. This means your code is easier to read and work with, and you can move around and edit code more efficiently. While some features are still experimental, using nvim-treesitter can greatly improve your coding experience in Neovim. https://github.com/nvim-treesitter/nvim-treesitter

GitHub Trends

@githubtrending · Post #14955 · 13.07.2025 г., 13:00

#shell#awesome#awesome_list#neovim#neovim_plugins#nvim_lua Neovim is a powerful, extensible text editor based on Vim, designed for usability and customization. It supports a vast collection of plugins tailored specifically for Neovim features, including plugin managers, language servers (LSP), AI coding assistants, syntax highlighting, fuzzy finders, file explorers, Git integration, debugging tools, and more. These plugins enhance coding productivity by adding features like code completion, project management, smooth navigation, and UI improvements. Using Neovim with these plugins lets you create a personalized, efficient coding environment that can boost your workflow, support many programming languages, and integrate modern tools like AI assistants and debuggers directly into your editor. https://github.com/rockerBOO/awesome-neovim

GitHub Trends

@githubtrending · Post #15096 · 26.08.2025 г., 11:30

#lua#layout#lua#neovim#neovim_plugin#neovim_ui#nvim#plugin#scratchpad#ui#ux#zen_mode#zenmode The no-neck-pain.nvim plugin for Neovim centers your active editing window by adding empty buffers on each side, creating padding that keeps your focus in the middle of the screen. It works right away without setup, supports multiple tabs, split windows, and integrates with popular file tree and dashboard plugins. You can customize its width, colors, and behavior, and even use the side buffers as scratchpads for notes. This helps reduce neck strain and improves focus, especially on wide monitors, by keeping your code or text centered and easy to read without distractions. https://github.com/shortcuts/no-neck-pain.nvim