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 слични објави

Пребарај: #wayland

当前筛选 #wayland清除筛选
Linuxgram 🐧

@linuxgram · Post #18596 · 28.04.2026 г., 10:02

📰WayVNC 0.10 Released For Advancing This Leading VNC Server For Wayland WayVNC 0.10 is out today as the newest feature release for this VNC server that works with Wayland compositors leveraging the wlroots library... 🔗 Source: https://www.phoronix.com/news/WayVNC-0.10-Released #wayland

Hashtags

Linuxgram 🐧

@linuxgram · Post #18569 · 25.04.2026 г., 19:03

📰 Niri 26.04 Brings Long-Awaited Blur Support to the Wayland Compositor Niri 26.04 scrollable-tiling Wayland compositor adds long-awaited blur support, improved screencasting, faster rendering, and more. 🔗 Source: https://linuxiac.com/niri-26-04-brings-long-awaited-blur-support-to-the-wayland-compositor/ #wayland

Hashtags

Linuxgram 🐧

@linuxgram · Post #18464 · 16.04.2026 г., 19:14

📰 Mir 2.26 Begins Working On Rust-Based Input Platform Canonical today released Mir 2.26 as the newest feature release for this compositor for building Wayland-based shells. Notable with Mir 2.26 is a Rust-based input platform is in development as part of their broader effort for bringing Rust code into Mir... 🔗 Source: https://www.phoronix.com/news/Mir-2.26-Released #wayland

Hashtags

Linuxgram 🐧

@linuxgram · Post #18396 · 11.04.2026 г., 19:06

📰 Cage 0.3 Released With New Wayland Protocol Support Cage as the Wayland compositor providing a kiosk mode for single, maximized apps is out with a new feature release more than six months after its prior version... 🔗 Source: https://www.phoronix.com/news/Cage-0.3-Released #wayland

Hashtags

Linuxgram 🐧

@linuxgram · Post #18362 · 09.04.2026 г., 08:08

📰Miracle-WM 0.9 Makes This Mir-Based Wayland Compositor Truly Hackable Miracle-WM 0.9 brings WebAssembly plugins, a new Rust API, cursor theme support, and faster performance for this Mir-based Wayland compositor. 🔗 Source: https://linuxiac.com/miracle-wm-0-9-makes-this-mir-based-wayland-compositor-truly-hackable/ #wayland

Hashtags

Linuxgram 🐧

@linuxgram · Post #18353 · 08.04.2026 г., 16:37

📰 16 contributors, cross-stack improvements: Collabora's work on GStreamer 1.28 Our multimedia engineering team delivered major improvements to GStreamer 1.28: hardware acceleration and zero-copy pipelines, HDR and color support for Wayland, AI inference integration, plus critical codec and RTP/WebRTC interoperability fixes. 🔗 Source: https://www.collabora.com/news-and-blog/news-and-events/16-contributors-cross-stack-improvements-collabora-work-gstreamer-128.html #wayland

Hashtags

Linuxgram 🐧

@linuxgram · Post #18335 · 07.04.2026 г., 15:15

📰 Alacritty 0.17 Terminal Emulator Released with Wayland Resize Improvements Alacritty 0.17, a GPU-accelerated terminal emulator, adds TOML 1.1 support, Wayland resize increments, mouse wheel bindings, and more. 🔗 Source: https://linuxiac.com/alacritty-0-17-terminal-emulator-released-with-wayland-resize-improvements/ #wayland

Hashtags

Linuxgram 🐧

@linuxgram · Post #18270 · 01.04.2026 г., 13:26

📰 Wayland Protocols 1.48 Released With XDG Session Management Wayland Protocols 1.48 is out today with the long-awaited XDG Session Management protocol in tow as well as several new experimental protocols... 🔗 Source: https://www.phoronix.com/news/Wayland-Protocols-1.48 #wayland

Hashtags

Linuxgram 🐧

@linuxgram · Post #18215 · 27.03.2026 г., 19:15

📰Hyprland 0.54.3 Wayland Compositor Released With Crash Fixes Hyprland 0.54.3 delivers fixes for crashes in compositor, layout handling, and XWayland, improving overall stability in this patch release. 🔗 Source: https://linuxiac.com/hyprland-0-54-3-wayland-compositor-released-with-crash-fixes/ #wayland

Hashtags

Linuxgram 🐧

@linuxgram · Post #18116 · 19.03.2026 г., 16:46

📰 Wayland 1.25 Released With Color Management Now Fully Documented Article from Phoronix. Read more at the original link. 🔗 Source: https://www.phoronix.com/news/Wayland-1.25-Released #wayland

Hashtags

Linuxgram 🐧

@linuxgram · Post #18074 · 16.03.2026 г., 12:53

📰 River 0.4 Wayland Compositor Debuts Pluggable Window Managers River 0.4 introduces a new architecture separating the Wayland compositor from the window manager. 🔗 Source: https://linuxiac.com/river-0-4-wayland-compositor-debuts-pluggable-window-managers/ #wayland

Hashtags

Linuxgram 🐧

@linuxgram · Post #17990 · 06.03.2026 г., 09:26

📰 Wayland 1.25 RC1 Released With Improved Documentation, Minor Changes Simon Ser announced the release today of Wayland 1.25 RC1 (Wayland v1.24.91) in working toward this next stable release... 🔗 Source: https://www.phoronix.com/news/Wayland-1.25-RC1 #wayland

Hashtags

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