@fight4f · Post #8275 · 06.05.2024 г., 13:03
荷蘭的英文版每日更新 https://ig.me/j/AbZXhCHKgod1rjEq/ #engels
Hashtags
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
Пребарај: #engels
@fight4f · Post #8275 · 06.05.2024 г., 13:03
荷蘭的英文版每日更新 https://ig.me/j/AbZXhCHKgod1rjEq/ #engels
Hashtags
@druschbaFm_en · Post #52330 · 20.03.2025 г., 08:04
⚡️ 🇷🇺 🇺🇦⚔️ Ukraine Fronts on the Morning of 20 March⚡️ 🔴#Sumy Direction: 🔴In #Sudzha Sector, in the west, fighting continues in and near #Zhuravka, as well as southeast of it in #Basovka on Ukrainian territory. 🟡 In #Kursk region, fierce battles in the areas of the #Gogolevka and #Guyevo villages continue. 📌 Referring to Previous Reports, doubts have arisen as to whether fights are already taking place in the villages. There is still no objective control footage. We have corrected our arrows on map accordingly, which show the control and mentioned locations. 🟡#Oleshnya and #Gornal remain safe under AFU control. 🔴 In #KrasnayaYaruga Sector, south of #Sudhza in Russian #Belgorod region, further massive AFU assaults especially on #Demidovka, as well as in the areas of #Grafovka and #Prilesye have been foiled. The search for the remnants is ongoing. 🗺 All on Map 1 ✈️An AFU F16 was downed. 📌 The AFU Command is reportedly reinforcing all areas and intends to continue also the attacks on #Belgorod region. 🔴 In #Kharkov Direction, without significant changes. 🔴#Svatovo Front: 🔴 In #Kupyansk Sector, fierce fighting along the LoC continues, but without changes. 🔴 In #Borovaya Sector, the battle for #Boguslavka continues. 🔴In #Liman Sector, the RFAF advanced west of the #BalkaZhuravka settlement. 🔴In #Seversk Sector, fights in the area of #Bologorovka (#LPR) and in #Verkhnekamenskoye continue. 🔴#ChasovYar Direction: 🔴In #ChasovYar Sector, the northwestern part of the city is almost completely under Russian control. The battle for the centre southwest of the 'Refractory Plant' continues. Russian troops attacked from the east with armoured vehicles. The result of the battle is disputed. 🗺 Map 2 🎬 Video 1 🔴In #Toretsk Sector, northeast of the city, RFAF units attacked northeast of the #Druzhba settlement towards positions taken by Russian assaults beyond the canal near #Ozeryanovka. 🟡 In #Toretsk itself, the RFAF expanded their zone of control. 🔴#Pokrovsk Direction: 🔴 On the right Flank and south of the city, without significant changes. 🔴 On the left Flank, the battle for #Udachnoye continues as usual. 🟡 In #Uspenovka, the fierce battle continues and towards #Novoalexandrovka southwest of it. 🟡 In #Preobrazhenka, fighting for the eastern settlement part continues. To the south, the Russian troops are attacking towards #Troitskoye and #Bogdanovka. 🔴#Komar Direction: 🔴In #Konstantinopol Sector, the RFAF advanced west of #Slavyanka and north of #Andreyevka, but were driven out of a stronghold northwest of the latter. 🟡 In #Konstantinopol, the battle continues. 🔴 In #Komar Sector, the yesterday reported Russian advance south of #Privolnoye has been confirmed, the fights for the village itself continue. 🔴#Zaporozhye Direction: 🔴In the #Orekhov Section, north of #Rabotino the RFAF attack towards #Novodanilovka and further west in the direction of #Novoandreyevka. 🟡 For #Shcherbaki and #MalyeShcherbaki, the battle continues. 🟡#Stepovoye came, according to unconfirmed reports, under Russian control, as well as heights north of it. 🟡 For #Lobkovoye, the battle has begun with fights in the village (unconfirmed), alternate on its approaches. 🔴 In #Kherson Direction, without significant changes. 💥#OldRussia: 🔵In #Voronezh Region, ca. 40 AFU UAVs were downed overnight. In the #Saratov region, Zelensky tried to raid the Oil Refinery in #Engels, as a result of which the 'City Clinical Hospital No. 1' has been damaged. In the #Rostov region, another UAV attack was repelled. In #Gorlovka (#DPR), 11 civilians were wounded yesterday by Zelensky's morning shelling of the city centre. 💥#RestUkraine: 🔵 In #Kirovograd Region, in turn, after a massive Geranium UAV attack, more than 30 explosions occurred in the town of #Kropyvnytsky. 🎬 Video 2 🎞 Vids Source 1; Source 2; 🗺 Maps @olegtsarov; @creamy_caprice 📋 Sources: CC; Tsarov; ⚡️2M; 🇺🇦Fiend; 😼Kotenok 🕰20 Mar 2025; 06:44 GMT+3; #smo 📱 Join GLOBAL DEPTH to boost your TG Feed 💬Welcome to Military Chat & Ukraine Observer
Hashtags