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

Пребарај: #mirnoye

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

@druschbaFm_en · Post #52600 · 27.03.2025 г., 08:02

⚡️ 🇷🇺 🇺🇦⚔️ Ukraine Fronts on the Morning of 27 March⚡️ 🔴#Sumy Direction: 🔴In #Sudzha Sector, to the west on Ukrainian soil, at #Vladimirovka, there is reportedly fighting (still unconfirmed without further proof; 1st blue arrow on map). 🟡 For #Veselovka, the battle is ongoing (1st black arrow). 🟡 In #Zhuravka as well. 🟡 In #Basovka, the AFU counterattacked, the battle likely shifted to its northern part. 🟡#Novenkoye, is Russian controlled (1st red arrow). 🟡 In #Kursk region, the RFAF entry into #Gogolevka has been confirmed. Reportedly, the fighting has already shifted to its southern part (4th black arrow). 🟡 In the area of the 'Sudza Gas Transmission Point' and the nearby border checkpoint, the fighting continues (5th black arrow). 🟡#Melovoy is under Russian control (2nd red arrow). To its west, Russian mobile groups continued to advance towards #Oleshnya (confirmed). 🟡#Oleshnya is still under AFU control. 🟡 At #Guyevo, there are heavy battles on its approaches. Reportedly, the RFAF have entered its northern part. 🗺 Map 2 🟡#Gornal remains under save AFU control. 🔴In #KrasnayaYaruga Sector, the AFU assaulted unsuccessfully in its northern part from #Popovka/#Demidovka up to #Grafovka, suffering heavy losses (6th/7th black & 3rd red arrow). 🎬 Video 🟡 At #Prilesye, lull. 🗺 All on Map 1 📌Reportedly, the AFU command has concentrated a strike group of over 4,000 militants in the vicinity of the border. Thus, further actions are to be expected. 🔴 In #Kharkov Direction, positional battles. 🔴#Svatovo Front: 🔴 In #Kupyansk and #Borovaya Sectors, positional battles without major changes. 🔴In #Liman Sector, there was a fog of war. Reportedly, the RFAF took #Novolyubovka and the day before yesterday #Mirnoye (the takeover of #Yampolovka to its east was never confirmed or proven) and they advanced sooth of #Kolodezi by 2 km. 🔴In #Seversk Sector, positional battles at #Belogorovka (#LPR) and #Verkhnekamenskoye. 🔴#ChasovYar Direction: 🔴In #ChasovYar Sector, positional fighting in the city's southern part and to the south towards #Stupochki continues. 🔴In #Toretsk Sector, the RFAF attacks north of the city in the area of the 'Seversky Donets-Donbass Canal'. 🟡 In #Toretsk itself, the battles are taking place north of 'Toretskaya Mine,' north and northwest of 'Avangard Stadium' and in southern 'Zabalka Microdistrict'. 🔴#Pokrovsk Direction: 🔴 On the right Flank, far to the east, Russian troops attack in the area of #Aleksandropol. 🔴 South of the City, heavy battles did not result in major changes. 🔴 On the left Flank, the RFAF are approaching #Novoaleksandrovka. 🔴#Komar Direction: 🔴In #Konstantinopol Sector, fights for #Konstantinopol and at #Razliv. 🔴 In #Komar Sector, Russian troops advanced up to 400 m in #VolnoyePole and took up new positions in the central part of the settlement, taking heavy losses. 🔴#Zaporozhye Direction: 🔴In #Orekhov Section, positional battles are taking place In the area of ​#​MalayaTokmachka - #Rabotino. Further west, the AFU unsuccessfully counterattacked. 🟡 In #Shcherbaki, the RFAF took reportedly the southern part beyond the motorway. 🟡 At #MalyeShcherbakito the west, the battle continues. The village is still not completely under RFAF control. 🟡 In #Stepovoye, further west, fighting in the large village boundaries without major changes. 🟡 In #Lobkovoye, the the RFAF advanced slightly northwards (unconfirmed). 🟡#Pyatikhatki remains under RFAF control. 🔴 In #Kherson Direction, several villages came under fire from the AFU. 💥#OldRussia: 🔵In #Belgorod Region, Channel One journalist Anna Prokofiyeva was killed. 💥#RestUkraine: 🔵 The RFAF struck massively #Sumy, #Kharkov and #Dnepropetrovsk. ⚠️ The Term 'Reportedly' always means that it is unconfirmed! 🎞 Video Source 🗺 Maps @olegtsarov; @divgen 📋 Sources: CC; Tsarov; ⚡️2M; 🇺🇦Fiend;😼Kotenok 🕰As of 27 Mar 2025; 06:38 GMT+3;📃26 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