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

Резултати

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

Пребарај: #cultural

当前筛选 #cultural清除筛选

Taipei Performing Arts Center. The long-awaited Taipei Performing Arts Center in Taiwan has been completed by Rem Koolhaas-led studio OMA ahead of the official opening on 7 August 2022. Design architect: OMA Partners-in-Charge: Rem Koolhaas and David Gianotten Executive architect: KRIS YAO | ARTECH Theater consultant: dUCKS Scéno, Creative Solution Integration Ltd Acoustic consultant: Royal HaskoningDHV and Theo Raijmakers. Structure, MEP, building physics, fire engineer: Arup Lighting consultant: Chroma 33 Sustainability consultant: Segreene Design and Consulting Animation: Artefactory Photography: Chris Stowers and Shephotoerd Co. Photography Location: Taiwan #oma#arch_shovel#taiwan#theatres#architecture#cultural

The Vltava Philharmonic Hall. The new Vltava Philharmonic will be built by the Danish architectural studio Bjarke Ingels Group (BIG). BIG plans to complete the new building in 2032. “The Vltava Philharmonic Hall is composed as a meandering journey from riverbank to rooftop. Public flows and belvedere plazas unite the city life of Prague to the music within. Its halls are formed for sight, fine-tuned for sound, and orchestrated for functionality and connectivity. From this rhythmic structure, a symphony of colonnades and balconies extend as platforms for public life. Expressive yet pragmatic, the new Philharmonic will ascend to form a key landmark for Prague - from river to roof.” Bjarke Ingels, Founder & Partner, BIG. #arch_shovel#conpetition#award#cultural#BIG#news#NewsArchitecture

🇺🇿 TIV matbuot kotibi

@TIVmatbuot · Post #333 · 14.01.2025 г., 15:48

ХАЛҚАРО МАЙДОНДА МАДАНИЙ ДИПЛОМАТИЯНИНГ ЎРНИ Юртимиз маданий дипломатияси концепциясида халқимизнинг жаҳонга машҳур тарихий, маданий ва маънавий қадриятлари, Ўзбекистоннинг қадимий меъморчилиги ва ўзига хос анъаналари муҳим ўрин тутади - Озодбек Назарбеков, Ўзбекистон Республикаси маданият вазири. #O'zbekiston #BAA#Маданий дипломатия Batafsil THE ROLE OF CULTURAL DIPLOMACY ON THE INTERNATIONAL STAGE Uzbekistan's cultural diplomacy is rooted in its globally renowned historical, cultural, and spiritual values, as well as its ancient architecture and unique traditions - Ozodbek Nazarbekov, Minister of Culture of the Republic of Uzbekistan. #Uzbekistan#UAE#Cultural diplomacy Read more Veb-sayt | Facebook | Telegram | Instagram | LinkedIn | X | WhatsApp

MessageInABottle

@mib_messageinabottle · Post #7065 · 08.08.2024 г., 21:37

What #Britain is witnessing is the beginning of Dark #Blairism. This is the final stage in the collapse of the country. 🇬🇧🪦🧵 The first iteration of Blairism was a happy-go-lucky affair. #Blair and co were #Marxists of a variety, but happy Marxists who rejected state #socialism and embraced #cultural radicalism - a new, freer society where different groups would live in harmony. ☘🌈❤️ But society rejected this vision. 😭 People had “biases” - a false consciousness of sorts, mostly amongst the uneducated #gammons and chuds. 🤮 They couldn’t get into #Oxbridge to study with Tony, so the state needed to be used to educate them..... 👏 Read More: https://threadreaderapp.com/thread/1821450407979167748.html