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

Пребарај: #foss

当前筛选 #foss清除筛选
Libreware

@libreware · Post #904 · 19.02.2021 г., 19:25

[email protected] - Drizzle in my repo today with 2 new apps. Most prominently: Watomatic – to help those of you still stuck at WhatsApp to leave that s(t)inking ship without being afraid "nobody can find you": it sends auto-responses to everyone writing you, telling them you've left and where to look. So: no more excuses, here's your door! https://apt.izzysoft.de/fdroid/index/apk/com.parishod.watomatic​ Further running: SpaceXFollower (SpaceX events, facts, statistics) and Auxio, a nice music player, added yesterday. Enjoy #foss#Android#apps with #fdroid!

AIGC

@aigcrubbish · Post #224 · 02.03.2026 г., 15:42

[$] The exploitation paradox in open source 自由开源软件(FOSS)运动的核心是赋予个人和组织自由与权力,但其发展历程中,总存在试图利用FOSS谋取私利的参与者。在2026年比利时根特的配置管理营(CfgMgmtCamp)上,Richard Fontana阐述了开源的“剥削悖论”:即反复出现的危机模式,一些参与者利用规则漏洞来限制自由或在社区中获得对他人的优势。他还讨论了弥补这些漏洞的尝试,以及有必要超越许可证本身,以寻求维持自由的其他手段。 原文链接:https://lwn.net/Articles/1058031/ #开源#FOSS#社区治理#软件自由 #AIGC Read more

Daily Channels

@dailychannels · Post #5942 · 26.03.2025 г., 01:00

Channel: FOSS Post Members: ~2.04K 💢 Username: @fosspost Description: FOSS Post is a high-quality online magazine about Linux and open source software. This channel posts daily news from all over the web too. Website: https://fosspost.org 🏷 Tags: #technology #linux#open_source#foss#technology#free_software https://telegramchannels.me/channels/fosspost

GitHub Trends

@githubtrending · Post #15615 · 15.04.2026 г., 11:30

#python#android#android_apps#f_droid#foss#free_and_op#free_and_open_source#izzyondroid#open_source#opensource This list offers free open-source Android apps for every need—from browsers, cameras, and music players to games, tools, and F-Droid stores like Neo-Store. Get them via F-Droid or IzzyOnDroid for no ads or tracking. It boosts your privacy and freedom by ditching Google apps, letting you control your data and phone fully. https://github.com/offa/android-foss