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

Пребарај: #peacenegotiations

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

@CryptoM · Post #65310 · 12.04.2026 г., 20:05

🚀 Global Markets Brace for Volatility Amid Renewed Iran Conflict Concerns The potential resurgence of conflict in Iran following unsuccessful peace negotiations is raising concerns about increased volatility in global markets. Bloomberg posted on X that the recent fragile ceasefire had previously led to a significant rise in stock prices and a notable decrease in oil prices, marking the largest shifts seen this year. However, with the peace talks failing, market stability is once again under threat, prompting investors to brace for potential fluctuations. #GlobalMarkets#Volatility#IranConflict#PeaceNegotiations#OilPrices#StockMarket#Investors#MarketStability

Crypto M - Crypto News

@CryptoM · Post #65376 · 13.04.2026 г., 03:04

🚀 AI Technology Presents New Opportunities Amid Potential Financial Crisis On April 13, Liquid Capital founder Yi Lihua expressed optimism about the potential resolution of ongoing conflicts, noting that motivations for continued warfare are diminishing. According to BlockBeats, Yi emphasized that peace negotiations typically evolve from disagreement to consensus, suggesting that the conflict may gradually come to an end. He remarked that both sides have no reason to continue fighting, and the moment an agreement is reached could signal a positive market shift. Yi highlighted that, in the medium to long term, the market is anticipating a potential large-scale financial crisis. He observed defensive strategies in the financial sector, such as major capital holding high cash ratios and sovereign entities increasing gold reserves. In this context, if another crisis occurs, it will be a crucial test for Bitcoin's status as a safe-haven asset and may offer significant opportunities for low-level investment. Furthermore, Yi Lihua believes that AI technology is creating new opportunities for talented entrepreneurs. He noted that small teams can develop global products, reducing costs associated with financing and organizational management. Experienced serial entrepreneurs, in particular, should seize the opportunities presented by this "AI Age of Exploration." #AI#FinancialCrisis#Investment#Bitcoin#Entrepreneurship#Innovation#MarketOpportunities#Technology#PeaceNegotiations#GlobalProducts#BTC

Crypto M - Crypto News

@CryptoM · Post #65062 · 10.04.2026 г., 17:45

🚀 Iran's Leadership Revamp Amid Peace Talks with the US The ongoing conflict in Iran has prompted significant changes in the nation's leadership structure. Bloomberg posted on X that the Revolutionary Guards are set to play a pivotal role in the upcoming peace negotiations with the United States this weekend. This shift in power dynamics underscores the growing influence of the Revolutionary Guards in Iran's political landscape. The talks are expected to address key issues surrounding the conflict and aim to establish a framework for peace. Observers are closely watching how the involvement of the Revolutionary Guards will impact the discussions and the potential outcomes of these negotiations. #Iran#LeadershipRevamp#PeaceTalks#RevolutionaryGuards#USIranRelations#PoliticalLandscape#ConflictResolution#IranPolitics#PeaceNegotiations

Crypto M - Crypto News

@CryptoM · Post #65331 · 12.04.2026 г., 23:34

🚀 Middle East Nations Urge U.S. and Iran to Resume Talks After Failed Peace Negotiations According to BlockBeats, on April 13, The Wall Street Journal reported that following unsuccessful marathon peace talks in Islamabad, Middle Eastern countries are urging the United States and Iran to return to negotiations. Despite both sides issuing strong statements, diplomatic channels remain open, and a second round of talks could occur within days. Regional nations are in discussions with the U.S. to extend the fragile two-week ceasefire announced on Tuesday evening. Iranian officials have proposed alternative suggestions, such as continuing symbolic uranium enrichment activities or reducing their enriched uranium stockpile, but no compromise has been reached. #MiddleEast#USIranTalks#PeaceNegotiations#Diplomacy#Ceasefire#IranUranium#BlockBeats#Islamabad#Iran#MiddleEasternNations#WallStreetJournal