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

Резултати

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

Пребарај: #sydney

当前筛选 #sydney清除筛选
Papa & Vaticano - News

@papaevaticanonews · Post #8714 · 15.12.2025 г., 15:50

"Profondamente addolorato nell’apprendere del terribile attacco avvenuto a #Sydney, che ha causato la morte di membri della comunità ebraica riuniti per una celebrazione di Hanukkah, Papa #LeoneXIV assicura la sua vicinanza spirituale a tutti coloro che sono stati colpiti da questo insensato atto di violenza". Questo è quanto si legge in un telegramma, a firma del Segretario di Stato, il Cardinale Pietro Parolin, che il Pontefice ha inviato a mons. Antony Colin Fisher, O.P., Arcivescovo di Sydeny. "Con rinnovata speranza che quanti sono tentati dalla #violenza possano intraprendere un cammino di conversione e cercare la via della pace e della solidarietà", il Vescovo di Roma "prega per la guarigione di coloro che sono ancora in fase di recupero, così come per il conforto di quanti piangono la perdita di una persona cara. Affidando i defunti alla misericordia amorevole di Dio onnipotente, il Santo Padre invoca le divine benedizioni di pace e di forza su tutti gli australiani".

Opportunities with Zula

@opportunities_zula · Post #1007 · 15.01.2026 г., 16:13

One More Chance and Last Chance ! Apply for the Future Action Summit Australia 🇦🇺 2026 (Fully Funded) Apply: https://echochange.org/fas-australia-april-2026/?ref=20 Youth Summit in Sydney. The Program Covers Return Airfare, Accommodation, Meals, Certificates, Invitation Letter. Deadline: 18th Jan 2026 #FAS#Sydney#OpportunitiesCorners

Opportunities with Zula

@opportunities_zula · Post #906 · 30.12.2025 г., 01:55

Australia Future Action Summit 🇦🇺 2026 (Fully Funded) Apply: https://echochange.org/fas-australia-april-2026/?ref=20 International Youth Summit in Sydney in April 2026. The Program Covers Return Airfare, Accommodation, Meals, Certificates, Invitation Letter. Deadline: 12 Jan 2026 #FAS#Sydney#OpportunitiesCorners

Reuters: World

@reutersworldchannel · Post #149152 · 09.10.2021 г., 08:26

'Living seawalls' bring back biodiversity Scientists have installed more than 1,000 specifically designed panels onto existing seawalls in Sydney, mimicking the natural shoreline ecosystem like rock pools and mangroves. #News#Reuters#Climate#Australia#Sydney Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖

12
ПретходнаСтраница 1 од 2Следна