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

Резултати

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

Пребарај: #solenoye

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

@druschbaFm_en · Post #52752 · 01.04.2025 г., 07:57

⚡️ 🇷🇺 🇺🇦⚔️ Ukraine Fronts on the Morning of 1 April⚡️ 🔴 In #Chernigov Direction, the AFU has reportedly already crossed the Russian border of the #Bryansk region many times. Locals point to periodic incursions towards several villages. 🔴#Sumy Direction: 🔴In #Sudzha Sector, to the west on Ukrainian soil, the situation based on confirmed information and evidence is as follows: 🟡#Vladimirovka- AFU; {1st blue↗️}; 🟡#Vodolagi - AFU; 🟡#Uspenovka in Russia - contested {1st black↘️}; 🟡#Veselovka - contested {2nd black↖️}; 🟡#Belovody - AFU; 🟡 In #Zhuravka, fights in the central part; 🟡 In #Basovka, the RFAF assaults the eastern part. 🟡#Novenkoye - RFAF {1st red⬆️}. 🟡 In #Kursk region, reportedly, Russian troops have repelled an assault on the 'Border Checkpoint' {2nd red↙️}; the AFU have reinforced the battle area around #Oleshnya {4th blue⬅️}. 🟡 In #Guyevo, the RFAF have reportedly extended their control zone {5th black⬇️}. 🟡#Gornal remains AFU controlled. 🔴In #KrasnayaYaruga Sector, reportedly positional battles are taking place in #Popovka {6th black↙️}. 🟡 In #Demidovka, the AFU have advanced in the central part and in the area of ​​the farm in the village's eastern part. 🗺 Map 2 🟡 At #Grafovka and #Prilesye, lull. 🗺 All on Map 1 🔴#Kharkov Direction: 🔴In #Liptsy Section, positional battles. 🔴 In #Volchansk Section, as well in the city itself. 🔴#Svatovo Front: 🔴 In #Kupyansk and #Borovaya Sectors, reportedly slight tactical successes for the RFAF without major changes. 🔴In #Liman Sector, fighting south of #Katerinovka and east of #Novoye in the north. 🔴In #Seversk Sector, west of #Belogorovka, Russian troops reportedly approached #Grigorovka. 🔴#ChasovYar Direction: 🔴In #ChasovYar Sector, the battles continues. 🔴In #Toretsk Sector, fighting in the city and to the west for #Shcherbinovka and #Leonidovka continued. 🔴#Pokrovsk Direction: 🔴 On the right Flank, far to the east, fighting continues at #Valentinovka and in the area of #Panteleymonovka (towards #Toretsk northwards). To the west, urban battles in #Tarasovka. 🔴 South of the City, reportedly Russian advance in #Lysovka. Battles at #Shevchenko and #Peschanoye, and in #Kotlino fighting at the the far southeastern edge. 🔴 On the left Flank, the fighting for #Udachnoye's far southeastern reportedly continued. Otherwise, intense combat is taking place along the entire frontline from #Solenoye southwards. 🔴#Komar Direction: 🔴In #Bogatyr Sector, the battles near #Andreyevka and for #Konstantinopol continue. 🟡 In #Razliv, Russian troops extended the zone of control and raised the flag in the centre of the village. 📌Despite several Russian claims, there is no takeover yet! The village boundaries extend to the west, especially the large buildings with blue roofs are located within them. 🎬 Video 🗺 Map 3 🔴 In #Komar Sector, the RFAF are reportedly attacking towards #Otradnoye and #Komar. 🟡 In #Vesyoloye, the battle for the settlement is ongoing. 🔴#Zaporozhye Direction: 🔴In the #Orekhov Section, south of the city, the AFU positions are reportedly under permanent fire; Russian units are attacking towards #Novoandreyevka. To the west, the fighting especially in the 4 contested villages continues: 🟡#Shcherbaki; 🟡#MalyeShcherbakito the west; 🟡#Stepovoye, further west; 🟡#Lobkovoye; 🟡#Pyatikhatki remains RFAF controlled. 🟡 At #Kamenskoye, in the far west, the RFAF reportedly took one of the AFU's key strongholds. 🔴 In #Kherson Direction, Russian aviation struck Ukrainian positions on the opposite bank, while the AFU targeted villages. 💥 For #OldRussia and #RestUkraine, we have found no reports of new mutual strikes. ⚠️ The Term 'Reportedly' indicates that it is unconfirmed! 🎞 Video Source 🗺 Maps @olegtsarov; @petrenko_iHS@creamy_caprice 📋 Sources: CC; Tsarov; 🇺🇦Fiend;⚡️2M;🐈Cat😼VK 🕰As of 1 Apr 2025; 06:38 GMT+3;📃31 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

DruschbaFM - English

@druschbaFm_en · Post #52724 · 31.03.2025 г., 08:55

⚡️ 🇷🇺 🇺🇦⚔️ Ukraine Fronts on the Morning of 31 March⚡️ 🔴#Sumy Direction: 🔴In #Sudzha Sector, to the west on Ukrainian lands, the AFU counterattacked. Furthermore, video evidence has 👉emerged. As a result, the corrected situation (our added large arrows on map have been always correct) based on confirmed information and evidence is as follows: 🟡#Vladimirovka- AFU; {1st blue⬆️}; 🟡#Vodolagi - AFU {2nd blue⬆️}; 🟡#Uspenovka in Russia - contested {1st black⬆️}; 🟡#Veselovka - contested {2nd black⬆️}; 🟡#Belovody - AFU; 🟡#Zhuravka - contested; 🟡#Basovka - contested. 🟡#Novenkoye, RFAF {1st red⬆️}. 🟡 In #Kursk region, #Gogolevka and the 'Border Checkpoint' are RFAF controlled, an entry in #Oleshnya {4th blue⬅️} remained unconfirmed, fighting towards the village. 🟡 For #Guyevo, the battle continues. 🟡#Gornal is AFU controlled. 🔴In #KrasnayaYaruga Sector, the AFU in #Popovka and surrounding are under constant fire {6th black↙️}. 🟡 In #Demidovka, the battle on the ground continues. 🟡 At #Grafovka and #Prilesye, lull. 🗺 All on Map 1 🔴#Kharkov Direction: 🔴In #Liptsy Section and in #Volchansk, positional battles. 🔴#Svatovo Front: 🔴 In #Kupyansk Sector, Russian troops are expanding the bridgehead north of the city. 🔴In #Liman Sector, the battle for #Katerinovka has begun. 🔴In #Seversk Sector, fighting at #Belogorovka and towards #Verkhnekamenskoye. An entry into the latter remained unconfirmed. 🔴#ChasovYar Direction: 🔴In #ChasovYar Sector, without major changes. 🔴In #Toretsk Sector, the battle for the city continues. To the west, the AFU have further advanced in #Shcherbinovka and entered #Leonidovka. 🗺 Map 2 🔴#Pokrovsk Direction: 🔴 On the right Flank, far to the east, fighting continues in the area of #Panteleymonovka and #Aleksandropol, the full control of which is disputed. Northwest of the former, the RFAF advanced to the southern edge of #Valentinovka. To the west, the battle for #Tarasovka is ongoing. 🔴 South of the City, fighting for #Lysovka. #Shevchenko and #Peschanoye are RFAF controlled for now. East of #Kotlino the AFU advanced; in the village itself the RFAF at best hold the far southeastern edge (see 28 Mar). 🗺 Map 3 🔴 On the left Flank, Russian troops have at best presence in #Udachnoye's far southeastern part. The AFU have breached into #Solenoye. In #Uspenovka the RFAF reentered (earlier reports on clearing have not been confirmed) and attack towards #Novoaleksandrovka (reports on fights inside have not been confirmed). 🗺 Map 3 🟡#Nadezhdinka (#Nadeyevka) has been reentered by Russian forces (in the meantime, they have somehow lost control of the village). 🟡 Towards#Kotlyarovka and #Preobrazhenka, Russian assaults continue. 🔴#Komar Direction: 🔴In #Bogatyr Sector, the battle for #Konstantinopol continues. This contrary to 'Two Majors,' who have emphasised 'liberated' more than once (they know about the real facts). In #Razliv, the RFAF have consolidated their positions in the eastern, central and western parts of the settlement. 🔴 In #Komar Sector, the battle for #Novosyolka has shifted to the village's centre. 🔴#Zaporozhye Direction: 🔴In #Orekhov Section, the fighting continues. 4 villages remain contested: 🟡#Shcherbaki; 🟡#MalyeShcherbakito the west; 🟡#Stepovoye, further west; 🟡#Lobkovoye; 🟡#Pyatikhatki is RFAF controlled. 🗺 Map 4 🔴 In #Kherson Direction, the AFU shell villages. 💥#OldRussia: 🔵 AFU UAVs attacked #Bryansk, #Belgorod and Kursk regions, as well as #Crimea. 💥#RestUkraine: 🔵 The RFAFstruck with Iskanders in the #Sumy region, and 'Geraniums' worked in #Kiev, they reported a massive strike by UAVs on targets in the Zhitomir region. ⚠️ The Term 'Reportedly' indicates that it is unconfirmed, today without! 🗺 Maps @olegtsarov; @z_arhiv 📋 Sources: CC; Tsarov; 🇺🇦Fiend;⚡️2M;🐈Cat😼VK 🕰As of 31 Mar 2025; 07:26 GMT+3;📃29 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