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

Пребарај: #naturalresources

当前筛选 #naturalresources清除筛选
Amazing Geography 🌍

@amazingeo · Post #419 · 28.10.2025 г., 12:31

🌍 Over 80% of the world’s phosphorite—used for fertilizer—comes from just five countries. This concentration makes global food production highly dependent on a few natural resource deposits. ✨ #naturalresources⚡#minerals⚡#agriculture⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #604 · 31.01.2026 г., 12:31

🌍 In Chile’s Atacama Desert, salt flat brines supply much of the world’s lithium—a key mineral for rechargeable batteries—mined from groundwater beneath ancient salt crusts in one of Earth’s driest places. ✨ #naturalresources⚡#mining⚡#desert⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Venezuelanalysis

@venanalysis · Post #1764 · 02.10.2024 г., 21:40

Subsoil Bonanza: Venezuela’s Natural Resources Venezuela possesses the world’s largest oil reserves, but those are not the country’s only underground riches. From natural gas to gold, from bauxite to coltan, the Caribbean nation has no shortage of natural resources. It is no wonder it remains firmly in the crosshairs of global powers. For the full and interactive infographic click here 👉🏼https://shorturl.at/ilYnL #gold#naturalresources#oil#infographic#vainfographic

Crypto M - Crypto News

@CryptoM · Post #64773 · 09.04.2026 г., 21:50

🚀 Venezuela's National Assembly Approves New Mining Law to Attract Foreign Investment Venezuela's National Assembly unanimously passed a new mining law on Thursday, which includes 131 articles aimed at garnering support from the United States and attracting foreign investment. According to Jin10, the law features provisions that support foreign investment, such as an 'economic balance' clause and international arbitration options, differing from the 1999 framework that restricted disputes to local courts. The legislation introduces a simplified tax system, with royalties up to 13% of production and a new mining tax up to 6% of total revenue, while exempting several existing taxes. The maximum concession period is extended to 30 years, up from the previous 20 years, with the possibility of two 10-year extensions. Officials stated that the reform aims to attract investment in projects involving gold, bauxite, and other strategic minerals. However, the government retains the authority to designate certain resources or areas as national interests and impose special conditions. #Venezuela#MiningLaw#ForeignInvestment#Gold#Bauxite#EconomicReform#TaxIncentives#NaturalResources#NationalAssembly#InternationalArbitration