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

Резултати

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

Пребарај: #podol

当前筛选 #podol清除筛选
DruschbaFM - English

@druschbaFm_en · Post #52019 · 13.03.2025 г., 07:57

⚡️🇷🇺🇺🇦⚡️ Two Majors #Summary for the Morning of 13 March 2025; 06:46 (GMT+3)⚡️ 🎯 Enemy Sources reported another wave of strikes using FABs with UMPC, OTRK, and 'Geranium' drones. Explosions were reported in the #Sumy, #Kherson, #Nikolayev, #Odessa, #Khmelnitsky, #Dnepropetrovsk, #Zaporozhye, #Kiev and #Cherkassy regions. 🔹 In #Kursk Region, the key event was the liberation of #Sudzha.🗺👆 Russian forces have full control of the city, conducting clearing operations against remaining enemy fighters hiding in basements and shelters. The settlements of #Podol and #Melovoy have also been secured. Dozens of civilians, who had survived under enemy occupation, were evacuated from the liberated villages. The AFU continues launching long-range US MLRS strikes on the region. Yesterday morning, the AFU attacked a feed factory in the village of #Kozyrevka, Bolshesoldatsky district, killing four employees and seriously wounding another. The Supreme Commander visited the command post of the Russian Grouping, setting the task of expanding the buffer zone along the border and fully defeating enemy forces in the #Kursk region. 🔹 In #Sumy Region, meanwhile, clashes continue along the #Novenkoye – #Basovka axis. 🔹 In #Liman Section, fighting is ongoing towards #Novoye and south of #Yampolovka, where the AFU is offering organised resistance and bringing in reserves. 🔹 In #Toretsk, the situation remains unchanged. The enemy continues infiltrating units into the urban area. While the AFU has no chance of altering the situation, eliminating the enemy groups that have managed to break through consumes time and resources. 🔹 In #Pokrovsk Direction, Russian forces are attacking in the areas of #Uspenovka, #Udachnoye, and #Kotlino. Heavy fighting continues in #Peschanoye and #Shevchenko, with no significant territorial gains for a long time. The enemy has reinforced this sector with reserves, including units trained in EU countries, and is suffering heavy losses in counterattacks. South of #Yasenevo, Russian forces are also attacking to straighten the front line. 🔹 On the #Vremyevka Ledge, Russian forces have raised the flag over the northern part of #Dneproenergiya, confirming the capture of the settlement. 🔹 On the #Zaporozhye Front, intense combat continues in the #Orekhov direction and on the approaches to #Shcherbaki. Russian forces are making progress, and positive developments from this axis are expected. 💥 In #Belgorod Region, the AFU Nazis continues their attacks. In the hamlet of #Tserkovny, Belgorod district, a drone struck a civilian car. Another vehicle was attacked by an FPV drone in the village of #Terebreno, Krasnoyaruzhsky district. A social facility was hit in #Tishanka, Volokonovsky district. In #Shvedunovka, Valuysky district, a drone detonated near a private house. 💥 In the #DPR, in #Nikolskoye, Volnovakha municipal district, a man born in 1975 was killed by the detonation of an explosive device. Near a reservoir in #Ilovaysk, a 17-year-old boy was injured due to the detonation of an explosive device. 💬Welcome to Military Chat; 🇬🇧Battle Maps 📱 Join GLOBAL DEPTH to boost your TG Feed GLOBAL DEPTH from #HK This channel aims to unite interested individuals from around the world in an attempt to connect the dots. Subscriber participation is always welcome here and in the channel's Chat Group.