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

Резултати

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

Пребарај: #nwo

当前筛选 #nwo清除筛选
Indian Development News 🇮🇳

@developmentnewsindia · Post #44329 · 02.05.2026 г., 10:27

Breaking: At the Peace Dialogues held between Pakistan and Afghanistan in Turkey, IHH, the org hosting the dialogue in Turkey, removed PoK, Balochistan and parts of Khyber Pantukhwa from Pakistan's map. #NWO#Geopolitics

Indian Development News 🇮🇳

@developmentnewsindia · Post #43826 · 20.04.2026 г., 04:43

BREAKING 🇦🇪⚡🇺🇸 A post on X by Abdulkhaleq Abdullah, adviser to the UAE president: “The UAE no longer needs the United States to defend it, as it has proven during Iranian aggression that it is fully capable of defending itself with competence.” “It is time to consider closing U.S. bases in the Arabian Gulf, as they are a burden on the UAE.” #Geopolitics#NWO

Indian Development News 🇮🇳

@developmentnewsindia · Post #43821 · 20.04.2026 г., 02:36

UAE to Trump Administration: "You started this war; if we run short of USDs as a result of it, either you will give us USD swap lines, or we will be forced to start transacting oil and gas in CNY and other currencies." -Via Wall Street Journal #NWO#geopolitics

Indian Development News 🇮🇳

@developmentnewsindia · Post #43877 · 21.04.2026 г., 07:14

🇯🇵 Prime Minister of Japan Sanae Takaichi "Today, we amended the 'Three Principles on Transfer of Defense Equipment and Technology' and their 'Guidelines for Implementation.' Until now, the overseas transfer of domestically produced finished products had been limited to search and rescue, transportation, surveillance, mine countermeasures (so-called 'five categories'), but with this amendment, transfers of all defense equipment will in principle become possible. In an increasingly severe security environment, no single country can now protect its own peace and security alone, and partner countries that support each other in terms of defense equipment are necessary." #InternationalNews#NWO

Indian Development News 🇮🇳

@developmentnewsindia · Post #43849 · 20.04.2026 г., 11:44

The US government has called on the defense contractor V2X to evacuate its employees from Kuwait and Iraq, warning the company that they could be targeted by Iran-backed militias, four sources said. #InternationalNews#NWO https://www.theguardian.com/world/2026/apr/20/defense-contractor-evacuate-iraq-kuwait

Indian Development News 🇮🇳

@developmentnewsindia · Post #43480 · 11.04.2026 г., 20:17

🇺🇸💰💵 US Dollar now represents ~46% of global FX and gold reserves, the lowest in at least 26 years. This percentage has declined -15 points since 2017. Excluding gold, the US Dollar makes up 57% of global reserve currencies, the lowest since 1994, according to IMF data. This comes as central banks have aggressively accumulated gold and diversified into other currencies. The last time the US Dollar fell below 50% of global reserves was in 1990-1991, a period marked by elevated inflation, a recession, and a crisis of confidence in the US economy. #InternationalNews#NWO

Политическая П

@politpe · Post #19932 · 16.02.2026 г., 19:25

🌎#nwo#макро Рэй Далио на Мюнхенской конференции по безопасности: - старый мировой порядок, установленный после 1945 года уже объявлен мертвым большинством мировых лидеров - сейчас мы находимся на «6-м этапе» большого цикла, где нет правил, сила — это право, и великие державы сталкиваются друг с другом - экономические войны обычно предшествуют настоящим войнам, где стреляют - в 1930-е годы были торговые войны, технологические войны, войны капитала и геополитические войны, продолжавшиеся около десяти лет, а потом в 1939 году началась настоящая война mt в max

12
ПретходнаСтраница 1 од 2Следна