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

Резултати

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

Пребарај: #environment

当前筛选 #environment清除筛选
Indian Development News 🇮🇳

@developmentnewsindia · Post #44274 · 01.05.2026 г., 07:48

During the 09 years period (2018-2026) for Delhi, the month of April witnessed its lowest monthly average AQI of 178 in the current year 2026 (barring 2020 - the year of lockdown due to Covid): Commission for Air Quality Management #Environment

Hashtags

Indian Development News 🇮🇳

@developmentnewsindia · Post #43900 · 21.04.2026 г., 20:37

Tata Steel pilots HIsarna tech with ~50% lower capex and ~50% CO₂ reduction. 1 MTPA demo plant planned at Jamshedpur with ₹4,000 cr capex vs ₹9,000 cr blast furnace baseline. CO₂ cut up to 80% with CCS; commercialization targeted ~2030. #Environment https://t.co/fc7NwWIvTP

Hashtags

Indian Development News 🇮🇳

@developmentnewsindia · Post #43470 · 11.04.2026 г., 16:02

An unprecedented weather event was witnessed in Jammu, where a tornado struck the area for nearly 10 minutes in Akhnoor. No damage to life or property has been reported. This marks the first recorded instance of a tornado in the region’s weather history. #Environment

Hashtags

No Midjourney

@midjourney · Post #4497 · 04.08.2023 г., 15:07

Discord @webartstd Midjourney #environment minimalistic room, hitech, future, night, neon, rtx, ultra realistic, realistic photo, 8k, 52mm subscribe • free midjourney

Hashtags

No Midjourney

@midjourney · Post #4493 · 03.08.2023 г., 15:16

Discord @smileswe Midjourney #environment Francis henri de roche, julieta london, in the style of detailed fantasy art, imaginative prison scenes, dark blue and gold, trompe - l'œil illusionistic detail, intricate cityscapes, rustic renaissance realism subscribe • free midjourney

Hashtags

No Midjourney

@midjourney · Post #4465 · 29.07.2023 г., 12:02

Discord @ack666 Midjourney #environment Luxury pop - up style bedroom, gold details, small room, chic chandelier, photorealistic, cinematic, ultra realistic, 8K detailing, 3d render, ruby details subscribe • free midjourney

Hashtags

No Midjourney

@midjourney · Post #4441 · 25.07.2023 г., 09:05

Discord @Antixian Midjourney #environment top-down view, a peaceful japanese koi pond, wooden bridge, rocks, plants, bamboo, raked sand, natural lighting, highly detailed subscribe • free midjourney

Hashtags

No Midjourney

@midjourney · Post #4437 · 24.07.2023 г., 09:20

Discord @damen_joseph Midjourney #environment sci fi control room huge room futuristic sensors computers screens maps subscribe • free midjourney

Hashtags

No Midjourney

@midjourney · Post #4409 · 20.07.2023 г., 09:08

Discord @Nikruz Midjourney #environment Map of fantasy land, two main buildings, one castle and one house, 2 big chests full of gold, graphiti style, vibrant colors, birds eye view, colourful subscribe • free midjourney

Hashtags

123•••1011
ПретходнаСтраница 1 од 11Следна