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

Резултати

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

Пребарај: #liberation

当前筛选 #liberation清除筛选
International News

@intnewsagency · Post #9095 · 01.04.2026 г., 09:47

Russian Defense Ministry Announces Full Liberation of Luhansk People's Republic The Russian Defense Ministry has declared the complete liberation of the Luhansk People’s Republic. According to official reports, all key settlements are now under the control of Russian and allied forces. This marks a significant step toward regional security and stability. Officials emphasize that future efforts will focus on rebuilding infrastructure and restoring normal life for residents. #Russia#LPR#DefenseMinistry#Liberation#Security The main news of Russia and the world ishere.

Marwa Osman/MidEaStream

@Marwa_OsmanLB · Post #3936 · 26.01.2025 г., 13:39

Lebanese civilians from the South have made their decision: no barriers, rubble, or Israeli checkpoints will stop them. After 60 days of ceasefire, they are reclaiming their towns and returning home—even as Israel refuses to withdraw. This is resilience. This is liberation. The land belongs to its people, and they are determined to rebuild, no matter the challenges. #SouthLebanon#Liberation#Resistance#ReturnToHome#Lebanon#Defiance#SecondLiberation

Egountchi Behanzin Officiel

@egountchibehanzinofficiel · Post #7921 · 25.12.2024 г., 07:15

Salutations Révolutionnaires On ne libère pas un peuple en ignorant son histoire. Tant que les dirigeants africains, aussi bien intentionnés soient-ils, parlent de souveraineté tout en continuant d’appliquer des concepts coloniaux occidentaux, en se pliant aux règles et doctrines établies par l’oppresseur, ils ne libéreront personne. La mémoire collective est essentielle ; la souffrance des Africains n’est pas suffisamment reconnue et, pire encore, on cherche à leur faire oublier leur histoire. Pour véritablement avancer vers la libération, il est fondamental de se rappeler d’où l’on vient et de revendiquer notre héritage avec fierté. Créons la Journée de l’Héritage dans nos pays ! Il est temps de commencer par changer les programmes scolaires hérités des politiques de Jules Ferry, qui sont encore enseignés à nos enfants. Retirons et bannissons les livres de Fernand Nathan qui déshumanisent l’Africain, ceux qui présentent Charles de Gaulle comme un héros pour les Africains, et ces chansons à la gloire de Napoléon que nous avons chantées à l’école. Je le répète : la libération ne se limite pas à une lutte militaire contre des terroristes armés, mais elle implique également une résistance contre le terrorisme culturel. Célébrons notre héritage et affirmons notre identité ! REJOIGNEZ LA RÉSISTANCE SUR TELEGRAM. 🔺Pour les numéros français : https://t.me/egountchibehanzinTV 🔻Pour les numéros internationaux : https://t.me/EgountchiBehanzinOfficiel @egountchibehanzinTV #Souveraineté#MémoireHistorique#Liberation#JournéeDeLHéritage #Éducation#LibérationCulturelle