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

Резултати

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

Пребарај: #crueltyfree

当前筛选 #crueltyfree清除筛选
EKOLOG.UZ| ENG

@ekologuzenglish · Post #11617 · 16.02.2026 г., 00:59

💄 Beauty or suffering? Do you know the hidden truth behind the cosmetics you use? The mascara, lipstick, pencils, and eyeliner we use every day may be linked to the suffering of thousands of animals. How? Many major cosmetic companies test their products on defenseless animals before releasing them to the market. For years, innocent rabbits, mice, and other animals have been subjected to painful experiments for cosmetic products that are not essential for life. ❗️ No living being should suffer simply to sell makeup. 🌍 A historic step was taken by California, which became the first U.S. state to ban the sale of cosmetics tested on animals. The law was signed in 2018 by Governor Jerry Brown and officially came into force in January 2020. This decision sent a powerful signal to the world and accelerated the global shift toward cruelty-free beauty. ✨ California showed that progress does not have to come at the cost of animal suffering. ✨ Compassion must always come before profit. ✨ Beauty should never be built on pain. Because true beauty is responsibility. #crueltyfree#environment#animalprotection#responsibleconsumption ☘️ Read the latest environmental news on @ekologuz. Follow us and send your suggestions and feedback via @eklguz_bot

Chollazo Exprés 🔥 Ofertas y Descuentos

@ChollazoExpres · Post #5809 · 14.01.2026 г., 09:30

💥3INA MAKEUP - The Every Single Day SPF50 Protege tu piel del sol y la luz azul con esta crema facial vegan y cruelty free ✅OFERTA: 10.88€ ❌ Antes: 22.95€ 💰Ahorras un 53%🔥 Alta protección contra los rayos UVA-UVB, hidratación con ácido hialurónico y cu 👉 Protege tu piel hoy mismo #proteccionsolar#acidohialuronico#vegan#crueltyfree#rebajas 🛰️Oferta publicada en Deporte y Outdoor