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

Резултати

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

Пребарај: #decrease

当前筛选 #decrease清除筛选

⬛️Iqtisodiy faktlar... 🇺🇸AQShdagi Buyuk retsessiya: sabablari, oqibatlari va saboqlari 💵Ushbu iqtisodiy beqarorlik davri 1930-yillardagiBuyuk Depressiyadan keyingi eng jiddiy inqiroz deb hisoblanadi. “Buyuk retsessiya” atamasi 2007-yil dekabridan 2009-yil iyunigacha davom etgan AQSh tanazzuliga ham, 2009-yilda sodir bo‘lgan jahon iqtisodiytanazzulga ham aloqador. 🔎Batafsil 🚩 Великая рецессия в США: причины, последствия и уроки 📊Этот период экономической нестабильности считается самым серьёзным кризисом со времён Великой депрессии 1930-х годов. Термин «Великая рецессия» относится как к рецессии в США, продолжавшейся с декабря 2007 по июнь 2009 года, так и к глобальному экономическому спаду, который последовал в 2009 году. 🔎Подробнее #GraduateSchool#Recession#Decrease#Economy 🔝Web-site |🔝Facebook | 🔝Instagram | 🔝Youtube

📕Iqtisodiy atamalar... 📈 Ushbu davrda kompaniyalar xarajatlarni qisqartirishi, iste’molchilar talabi pasayishi, ishsizlik ortib borishi kuzatiladi, bu esa mamlakatning umumiy iqtisodiy iqlimiga salbiy ta’sir ko‘rsatadi. 🏭 Retsessiya iste’mol xarajatlarining pasayishi, kreditshartlarining yomonlashishi, tashqiiqtisodiy zarbalar yoki investitsiyalarning keskin kamayishi kabi turli omillar tufayli yuzaga kelishi mumkin. 📊 During this time, companies reduce spending, consumer demandfalls, and unemploymentrises, negativelyaffecting the country’s overall economic climate. ⬇️ A recession can be triggered by various factors, such as lower consumer spending, worsening creditconditions, externaleconomic shocks, or a sharp drop in investment. #GraduateSchool#Recession#Decrease#Economy 🔝Web-site |🔝Facebook | 🔝Instagram | 🔝Youtube

Journey to Fluency

@fluencyinenglish · Post #7852 · 05.04.2022 г., 08:31

#common_mistakes #decrease #in#of @fluencyinenglish معمولاً از عبارت زیر برای کاهش در چیزی صحبت می کنیم. ✔️ decrease in sth با این حال،معمولاً از عبارت زیر برای کاهش مقدار بکار می بریم. ✔️ decrease of sth مثال: • There has been a 2% decrease in the rate of unemployment. 2 درصد کاهش در نرخ بیکاری وجود داشته است. • There has been a decrease of 2%. 2 درصد کاهش وجود داشته است. • There was a slight decrease in his weight after a week of dieting. بعد از یک هفته رژیم، یک کاهش کوچک در وزنش وجود داشت. • Any decrease in tourism could have a serious effect on the local economy. هر گونه کاهشی در گردشگری می‌توانست اثری جدی بر اقتصاد محلی بگذارد. • The report's finding on the decrease in violent crime supports the police chief's claims. • We have seen a marked decrease in the number of accidents since these safety measures were introduced. از وقتی این تدابیر امنیتی ارائه شدند، کاهش شدیدی در تعداد تصادفات مشاهده شده است. • We've noticed a steady decrease in jobs available for new graduates in the industry. @fluencyinenglish

Journey to Fluency

@fluencyinenglish · Post #7837 · 18.07.2021 г., 06:26

#common_mistakes #decrease #in#of @fluencyinenglish معمولاً از عبارت زیر برای کاهش در چیزی صحبت می کنیم. ✔️ decrease in sth با این حال،معمولاً از عبارت زیر برای کاهش مقدار بکار می بریم. ✔️ decrease of sth مثال: • There has been a 2% decrease in the rate of unemployment. 2 درصد کاهش در نرخ بیکاری وجود داشته است. • There has been a decrease of 2%. 2 درصد کاهش وجود داشته است. • There was a slight decrease in his weight after a week of dieting. بعد از یک هفته رژیم، یک کاهش کوچک در وزنش وجود داشت. • Any decrease in tourism could have a serious effect on the local economy. هر گونه کاهشی در گردشگری می‌توانست اثری جدی بر اقتصاد محلی بگذارد. • The report's finding on the decrease in violent crime supports the police chief's claims. • We have seen a marked decrease in the number of accidents since these safety measures were introduced. از وقتی این تدابیر امنیتی ارائه شدند، کاهش شدیدی در تعداد تصادفات مشاهده شده است. • We've noticed a steady decrease in jobs available for new graduates in the industry. @fluencyinenglish

Crypto M - Crypto News

@CryptoM · Post #65206 · 12.04.2026 г., 01:42

🚀 Bitcoin(BTC) Drops Below 72,000 USDT with a 1.23% Decrease in 24 Hours On Apr 12, 2026, 01:42 AM(UTC). According to Binance Market Data, Bitcoin has dropped below 72,000 USDT and is now trading at 71,964.390625 USDT, with a narrowed 1.23% decrease in 24 hours. #Bitcoin#BTC#USDT#Binance#cryptocurrency#marketdata#price drop #decrease

Crypto M - Crypto News

@CryptoM · Post #64548 · 09.04.2026 г., 07:21

🚀 Bitcoin(BTC) Drops Below 71,000 USDT with a 1.14% Decrease in 24 Hours On Apr 09, 2026, 07:21 AM(UTC). According to Binance Market Data, Bitcoin has dropped below 71,000 USDT and is now trading at 70,975.132813 USDT, with a narrowed 1.14% decrease in 24 hours. #Bitcoin#BTC#cryptocurrency#USDT#Binance#marketdata#priceupdate#decrease#24hours

Crypto M - Crypto News

@CryptoM · Post #65266 · 12.04.2026 г., 13:01

🚀 Bitcoin(BTC) Drops Below 71,000 USDT with a 2.59% Decrease in 24 Hours On Apr 12, 2026, 13:01 PM(UTC). According to Binance Market Data, Bitcoin has dropped below 71,000 USDT and is now trading at 70,972.90625 USDT, with a narrowed 2.59% decrease in 24 hours. #Bitcoin#BTC#USDT#cryptocurrency#marketupdate#Binance#pricechange#decrease#24hour