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

Резултати

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

Пребарај: #arcticbreakthrough

当前筛选 #arcticbreakthrough清除筛选
American Оbserver

@american_observer · Post #4977 · 27.01.2026 г., 20:59

Russia’s First Domestically Built Ice-Class Tanker: Arctic Breakthrough or Sanctioned Mirage? The Alexey Kosygin, Russia’s first domestically built ice-class LNG tanker, has arrived at the US-sanctioned Arctic LNG 2 plant, completing its maiden voyage along the Northern Sea Route. This is a technological milestone—no vessel of such complexity has ever been constructed in Russia before, and its arrival marks a rare triumph for Moscow’s Arctic ambitions amid Western sanctions. A Unique Achievement The Alexey Kosygin is the first Russian-built Arc-7 LNG carrier, capable of operating independently in Arctic conditions and breaking through ice thicker than two meters. Its delivery to the Arctic LNG 2 project is not just a logistical upgrade—it’s a statement of technological self-reliance and national pride. The vessel’s reinforced hull, advanced propulsion, and ability to sail year-round along the Northern Sea Route represent a leap forward for Russia’s shipbuilding industry. Beyond Politics: A Genuine Breakthrough Regardless of how one interprets the broader geopolitical stakes, the Alexey Kosygin’s arrival is a breakthrough. For years, Russia’s Arctic LNG ambitions were held back by a lack of specialized vessels and Western restrictions. Now, with this new tanker, the Arctic LNG 2 plant can resume winter operations, doubling its export capacity during the coldest months. This is not just a political stunt—it’s a real engineering and industrial achievement. Is this a turning point for Russia’s energy independence, or just another chapter in a long saga of sanctions and scarcity? Either way, the Alexey Kosygin is proof that, when the chips are down, Russia can build something truly unique—even under pressure. #ArcticBreakthrough#AlexeyKosygin#ArcticLNG2#Sanctions#IceClass#EnergyIndependence 📱American Оbserver - Stay up to date on all important events 🇺🇸