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

Пребарај: #goldreserves

当前筛选 #goldreserves清除筛选
Crypto M - Crypto News

@CryptoM · Post #64603 · 09.04.2026 г., 10:24

🚀 Czech Central Bank Increases Gold Reserves to 76.6 Tons As of the end of March 2026, the Czech Central Bank's gold reserves have reached nearly 77 tons, specifically 76.6 tons, according to data from the Czech Central Bank. According to Jin10, the World Gold Council reported that in February, the Czech Central Bank's gold reserves were approximately 75 tons, indicating an increase of 2 tons in February. The Czech Central Bank aims to increase its gold reserves to 100 tons by 2028. #CzechCentralBank#GoldReserves#Gold#MonetaryPolicy#Finance#Economy#PreciousMetals

Crypto M - Crypto News

@CryptoM · Post #64660 · 09.04.2026 г., 13:03

🚀 PRECIOUS METALS | Russia's Central Bank Reserves Increase to $767.5 Billion Russia's central bank reported an increase in its gold and foreign exchange reserves, reaching $767.5 billion for the week ending April 3. According to Jin10, this marks a rise from the previous value of $755.4 billion. The growth in reserves reflects ongoing adjustments in Russia's financial strategy amid global economic fluctuations. #Russia#CentralBank#GoldReserves#ForeignExchange#Finance#Economy#GlobalEconomy

Crypto M - Crypto News

@CryptoM · Post #65442 · 13.04.2026 г., 08:59

🚀 U.S. Dollar's Share in Global Reserves Hits Lowest Since 1994 The U.S. dollar currently represents approximately 46% of global foreign exchange and gold reserves, according to NS3.AI, citing data from the International Monetary Fund (IMF). When excluding gold, the dollar accounts for 57% of global reserve currencies, marking its lowest share since 1994. #USDollar#GlobalReserves#IMF#ForeignExchange#GoldReserves#ReserveCurrency #1994

Crypto M - Crypto News

@CryptoM · Post #64663 · 09.04.2026 г., 13:13

🚀 PRECIOUS METALS | Poland's Central Bank Holds 580 Tons of Gold Poland's Central Bank Governor, Adam Glapiński, has announced that the central bank currently holds 580 tons of gold. According to Jin10, this substantial reserve underscores Poland's strategic approach to strengthening its financial security and diversifying its assets. The gold holdings are part of a broader effort to ensure economic stability and safeguard against global market fluctuations. Poland's commitment to maintaining a robust gold reserve reflects its proactive measures in navigating the complexities of the international financial landscape. #Poland#CentralBank#GoldReserves#FinancialSecurity#EconomicStability#GlobalMarket#AssetDiversification#GoldHoldings#InternationalFinance