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

Пребарај: #nadiya

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

@druschbaFm_en · Post #52476 · 24.03.2025 г., 08:03

⚡️ 🇷🇺 🇺🇦⚔️ Ukraine Fronts on the Morning of 24 March⚡️ 🔴#Sumy Direction: 🔴In #Sudzha Sector, west of the embattled #Zhuravka on Ukrainian lands, the RFAF entered the northern outskirts of #Vladimirovka (or came close to; another black arrow on map). 🟡 In #Zhuravka, the battle continues. 🟡 In #Basovka, the RFAF advanced in its southern part. 🟡 At #Novenkoye, the RFAF advanced (1st red arrow). 🟡 In #Kursk region, the situation remained unchanged. #Rubanshchina remains Russian controlled (2nd red arrow), #Gogolevka, #Oleshnya, #Guyevo and #Gornal remain under AFU control for now (4 large blue arrows on map). 🟡 In #Melovoy, the battle continues (small black arrow). 🔴 In #KrasnayaYaruga Sector, the AFU continued to attack and could enter #Demidovka and gain a foothold in the ruined village's southern part. This morning, the battle for it and the adjacent forest plantations continues (red arrow turned to black). 🟡#Grafovka, remains under RFAF control. 🟡#Prilesye as well. 🗺 All on Map 1 📌Given the Events, the 1st AFU's minor interim result at high costs is of no strategic value whatsoever. On the contrary, the overall situation of the AFU has even worsened with the further aforementioned border crossing. 🔴#Kharkov Direction: 🔴In #Liptsy Section, positional battles are taking place. The frontline remained unchanged. 🔴 In #Volchansk Section, the same situation. 🔴#Svatovo Front: 🔴 In #Kupyansk Sector, Russian troops advanced in the eastern and western settlement parts of #Topoli and expanded the bridgehead towards the settlement of #Kamenka from the east. 🟡 In #Dvurechnaya, Russian infantry units advanced within the settlement boundaries. 🔴 In #Borovaya Sector, the AFU retook the settlement of #Nadiya and advanced in its area. 🎬 Video 1 🔴In #Liman Sector, without significant changes. 🔴In #Seversk Sector, as well. 🔴#ChasovYar Direction: 🔴In #ChasovYar Sector, there are reportedly fights in the city's southern 'Shevchenko Microdistrict,' and further south towards #Stupochki village. 🔴In #Toretsk Sector, fighting continues in the northern, central and southern parts of the city. 🔴#Pokrovsk Direction: 🔴 On the right Flank, the RFAF have entered the village of #Vodyanoye2nd west of #Tarasovka. 🗺 Map 2 🎬 Video 2 🔴 South of the City, the heavy fighting continued without any noteworthy results. 🔴 On the left Flank, there are ongoing heavy battles also without any tangible results. 🔴#Komar Direction: 🔴In #Konstantinopol Sector, fighting in and around the village of the same name and throughout the sector is ongoing. 🔴 In #Komar Sector, the battles continued without major changes. 🔴#Zaporozhye Direction: 🔴In the #Orekhov Section, fighting continues in #MalyeShcherbaki, to which Russian troops broke through several days ago and to the west near #Stepovoye. 🔴 In #Kherson Direction, the AFU have still presence in the area of ​​the 'Antonovsky Bridge,' where the RFAF disrupted another AFU rotation. Otherwise Russian artillery and Aerospace Forces are hitting AFU positions and facilities. 💥#OldRussia: 🔵 In #Rostov Region, Russian air defence repelled a massive AFU drone attack on several districts, as well as in #Novoshakhtinsk and on the approach to Rostov at night. In one of the #Voronezh region districts, more than five UAVs were destroyed. In the evening, the RF MoD reported dozens of destroyed drones in the #Crimea, #Belgorod, #Bryansk and #Kursk regions. In #Zaporozhye region, the AFU targeted an ambulance, killing a paramedic. In Pologi district the AFU disrupted the power supply. In the #DPR, 7 civilians were wounded by AFU strikes. ⚠️ This Report contains new info received after the usual 2-Majors morning report. 🎞 Vids Source 1; Source 2; 🗺 Maps @olegtsarov; @creamy_caprice 📋 Sources: CC; Tsarov; ⚡️2M; 🇺🇦Fiend;😼Kotenok 🕰As of 24 Mar 2025; 07:39 GMT+3;📃22 Mar 📱 Join GLOBAL DEPTH to boost your TG Feed 💬Join Military Chat for Comments & Discussions 🇺🇦On Ukraine Observer you will find your daily independent Ukraine War Battle Update