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

Пребарај: #busification

当前筛选 #busification清除筛选
Russian Consulate in Cape Town

@rusconct · Post #2422 · 08.04.2025 г., 18:47

🎙 Briefing by Russia's Foreign Ministry Spokeswoman Maria Zakharova(Moscow, April 3, 2025) 🔹 Russia's Foreign Minister Sergey Lavrov's schedule 🔹AFU strikes on Russia’s energy infrastructure 🔹Kiev regime crimes 🔹 Third anniversary of the Bucha hoax 🔹 Busification in Ukraine 🔹 New facts about Nazi criminals in Canada 🔹 Silence of the West regarding the attacks on the "Nord Streams" 🔹Russia’s humanitarian aid to Myanmar 📰Read 📺Watch *** The Kiev regime, having completely lost its sense of self-preservation and connection to reality, in its desperate attempt to disrupt the ongoing Russian-American dialogue at any cost, continues to employ blatantly terrorist methods, striking Russian energy infrastructure on a daily basis. At the same time, it is clear that these attacks hold no military value. The actions of the Kiev regime not only constitute war crimes but also represent a deliberate effort to sabotage any peace initiatives. The assurances given by Zelensky that they would honour the moratorium were broken on the very same day. #Ukraine#Busification Even Ukraine’s ombudsman could not turn a blind eye to rampaging corruption and arbitrary conduct by draft centres. In his report, he admitted the mass and systemic nature of human rights violations and abuse of power. He mentions evidence of using force, weapons and special devices against draftees, as well as forceful signing of documents, prevention of access to legal aid for these victims of so-called “busification”, a new term that refers to newly caught males aka future conscripts being put with use of force into buses against their will. Attorneys have been replaced by plain mobsters who charge thousands of dollars for the service of “rescuing” draftees. #Canada#Nazis A group of American historians led by Jared McBride, a history professor at the University of California, has recent gained access to typed and handwritten files with the names of Nazis and their accomplices who were given asylum in Canada, which are available online. The list was stored at the Library and Archives Canada. There are 774 names on it. They have mentioned the names of especially notorious persons, such as an founder of the 14th Galicia Division Vladimir Kubiyovich and Helmut Oberlander from the death squads of Sonderkommando 10a (Sk 10a), who participated in the massacres of children in the Krasnodar Krai in 1942-1943. This story is yet another reminder of the fact that the Canadian authorities encouraged Nazi criminals and their accomplices from collaboration units, including those guilty of the Holocaust,to move to Canada starting in 1948. These people were not called to account for their crimes but enjoyed protection and patronage.