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

Резултати

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

Пребарај: #hangsengindex

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

@CryptoM · Post #65343 · 13.04.2026 г., 01:23

🚀 Hong Kong Stocks Open Lower as Tech Shares Decline Hong Kong stocks opened lower today, with the Hang Seng Index dropping 0.71% and the Hang Seng Tech Index falling 0.69%. According to Jin10, technology stocks led the decline, with Baidu (09888.HK) down over 3% and NetEase-S (09999.HK) falling more than 2%. #HongKongStocks#HangSengIndex#HangSengTechIndex#TechStocks#Baidu#NetEase

Crypto M - Crypto News

@CryptoM · Post #64505 · 09.04.2026 г., 04:13

🚀 STOCKS | Hong Kong's Hang Seng Index Retreats After Previous Surge On April 9, Hong Kong's Hang Seng Index experienced a pullback following a significant rise of nearly 800 points the previous day. According to Jin10, the index opened over 100 points lower in the morning and briefly fell more than 200 points to reach 25,653.63 points before recovering slightly. By midday, the Hang Seng Index closed down 0.35% at 25,803.12 points, while the Hang Seng Tech Index fell 1.26% to 4,861.39 points. The total market turnover for the Hang Seng Index reached HKD 126.652 billion. In terms of sector performance, optical communication and computing infrastructure stocks led gains, while the innovative drug concept saw a brief surge in early trading. However, most technology stocks underwent a correction, with real estate and gold stocks experiencing notable declines. Among individual stocks, Yangtze Optical Fibre and Cable Joint Stock Limited Company (06869.HK) rose 3.2%, WuXi AppTec Co., Ltd. (02359.HK) increased by 3.53%, Kingdee International Software Group Company Limited (00268.HK) fell 5.49%, Kuaishou Technology (01024.HK) dropped 3.55%, and Longfor Group Holdings Limited (00960.HK) decreased by 4.07%. #HangSengIndex#HongKongStocks#StockMarket#TechStocks#RealEstate#Gold#MarketPullback#Trading#Investment

Crypto M - Crypto News

@CryptoM · Post #64465 · 09.04.2026 г., 01:23

🚀 Hong Kong Stocks Open Lower as Tech Shares Decline Hong Kong's stock market opened with losses today, with the Hang Seng Index down by 0.53% and the Hang Seng Tech Index dropping by 1.11%. According to Jin10, several technology stocks experienced declines, including Alibaba, which fell by 2.69%, and Kuaishou, which decreased by 2.53%. #HongKongStocks#HangSengIndex#TechShares#Alibaba#Kuaishou#StockMarket#TechDecline

Crypto M - Crypto News

@CryptoM · Post #64811 · 10.04.2026 г., 01:25

🚀 STOCKS | Hong Kong Stocks Open Higher with Semiconductor Gains Hong Kong stocks opened with gains as the Hang Seng Index rose by 0.54% and the Hang Seng Tech Index increased by 0.47%. According to Jin10, Hua Hong Semiconductor saw a rise of over 3.5%, while CATL and WH Group both experienced nearly 3% increases. In contrast, NIO faced a decline of more than 6.5%, and Baidu dropped over 3.5%. #HongKongStocks#HangSengIndex#HangSengTechIndex#Semiconductors#HuaHongSemiconductor#CATL#WHGroup#NIO#Baidu#StockMarket