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

Резултати

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

Пребарај: #oilfutures

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

@CryptoM · Post #65284 · 12.04.2026 г., 14:26

🚀 Oil Futures Surge as Trump Orders Naval Blockade of Strait of Hormuz Oil futures on Hyperliquid experienced a significant increase following U.S. President Donald Trump's directive to implement a naval blockade of the Strait of Hormuz. According to NS3.AI, West Texas Intermediate (WTI) crude oil perpetual futures surged by 7%, reaching $96.40, while Brent futures rose by 6% to $96. The trading volume for WTI futures hit $1.53 billion, ranking it as the third-most-traded instrument on the platform, following Bitcoin (BTC) and Ethereum (ETH). Emergency reserve releases have been compensating for a daily shortfall of approximately 4.5 to 5 million barrels, but this buffer is approaching its limit. #OilFutures#Trump#NavalBlockade#StraitOfHormuz#WTI#Brent#CrudeOil#EmergencyReserves#Hyperliquid#BTC#ETH

Crypto M - Crypto News

@CryptoM · Post #65223 · 12.04.2026 г., 04:14

🚀 Sky Co-Founder Rune Faces Losses in Leveraged Oil and S&P 500 Positions Sky co-founder Rune's leveraged positions have recently experienced significant losses. According to Odaily, data from Hyperbot indicates that Rune's sevenfold leveraged short position on the Nasdaq 100 was closed 16 hours ago. Currently, he holds long positions valued at approximately $518,000, including a 20-fold leveraged long position in WTI crude oil futures and a sevenfold leveraged position in Brent oil. Additionally, Rune maintains a 20-fold leveraged short position on the S&P 500, valued at $159,000. At present, all of Rune's positions are in a loss state, with the total value dropping to around $678,000, reflecting a floating loss of approximately $61,000 and an investment return rate of -22.68%. Rune initially entered these positions last month when oil prices were rising, achieving a floating profit exceeding $1 million. However, recent fluctuations and declines in oil prices have turned these positions from profit to loss. #Sky#Rune#LeveragedTrading#OilFutures#SP500#Nasdaq100#FinancialLoss#WTICrude#BrentOil#Investing#SKY

Crypto M - Crypto News

@CryptoM · Post #64472 · 09.04.2026 г., 01:47

🚀 Unusual Oil Market Activity Precedes U.S.-Iran Ceasefire Announcement On April 9, unusual trading activity occurred in the oil market just hours before U.S. President Donald Trump announced a ceasefire agreement with Iran. According to BlockBeats, at 19:45 GMT on Tuesday, investors unexpectedly sold 8,600 lots of Brent and U.S. oil futures during a non-active trading period, amounting to approximately $950 million. Less than three hours later, Trump officially announced a two-week ceasefire with Iran. This news caused oil futures to plummet by about 15% at Wednesday's opening, falling below the $100 mark. The strategic short positions resulted in significant profits within hours. This incident is not isolated; on March 23, similar unusual trading occurred 15 minutes before Trump announced a delay in striking Iranian energy facilities, leading to a 15% drop in oil prices. Since the escalation of U.S.-Iran tensions, daily oil trading volumes have doubled to millions of lots. Congressman Ritchie Torres has formally requested the SEC and CFTC to investigate these "suspicious" trades. Torres emphasized the need to examine the accounts involved due to the trades' speed, scale, and structure. Currently, CME and SEC have declined to comment, while CFTC previously stated it is "monitoring" market anomalies. #OilMarket#USIran#Ceasefire#TradingAnomalies#OilFutures#MarketManipulation#SEC#CFTC#BrentCrude#EnergyNews