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

Пребарај: #rep

当前筛选 #rep清除筛选
Daily Channels

@dailychannels · Post #6727 · 05.03.2026 г., 13:00

Channel: PANDABUY CNFANS HOOBUY FIND Members: ~49.16K 💢 Username: @pandabuy_fr Description: Cnfans hoobuy pandabuy find #cnfans #hoobuy #pandabuy Education purpose. https://beacons.ai/cnfindsofficial https://t.me/cnfans_chatfinds 🏷 Tags: #fashion_beauty #cnfans#hoobuy#pandabuy#fashion#rep https://lve.to/kq7ojd0h6d

🗺 Travel the World | Private Expeditions

@expeditionsworldwide · Post #11 · 08.08.2020 г., 05:16

Today I am adding a Stratis coin (#STRAT) to my portfolio, paired with #USDT on Binance. The coin looks attractive for a long-term investment. Purchasing it in my 10$ Experiment portfolio. The coin ranks 124th in the CoinMarketCap rating. Briefly about the project: #STRAT is a blockchain-based platform that makes it easy to develop, test and deploy C# applications on the dotNET framework. STRATIS will act as a blockchain-as-a-service (BAAS) platform for corporations and institutions. This will help the enterprises that have joined the project to quickly implement blockchain technology for use in various industries. 🎯 The mission of the STRATIS platform is to become a one-stop shop for all blockchain-based products. The technology is a clone of the core bitcoin code, with several advanced features and written in C# instead of C++. #STRAT increased in value from August 2016 ($ 0.023) to the summer of 2017 (about $ 7.71), which is 49,000% in 10 months. It became one of the few currencies to be adopted and implemented very quickly thanks to numerous trusted exchanges and cryptocurrency wallets such as Poloniex, Jaxx and Ledger. At the moment, the price is moving in a neat upward channel. We have already retested the mirror support level 0.5440 twice. We have 2 support zones around 0.50 and 0.40. According to the Fibonacci grid, growth is expected by 70% to the level of 0.9588, which is near the psychological $1. This is the 6th coin in my portfolio. Before that, I bought for $10 such coins as: #NEO, #EOS, #REP, #XRP and of course #BTC.

Libertà è ragione

@libertaeragione · Post #3964 · 25.09.2023 г., 10:01

#Elezioni#Francia#Senato Composizione del prossimo Senato: #REP (#LR-#SL-#RSM-#ASFE-#MAP-#LFA-#Reconquête)|EPP|NI: 139 seggi #SER (#PS-#MDC-#MPF)|S&D: 68 #UC (#UDI-#LC-#MoDem-#PRV-#AC-#CE-#TH)|RE|EPP: 51 #RDPI (#Renaissance-#GUSR-#MDM-#GR-#NFG-#ION)|RE: 22 #CRCE (#PCF-#GRS-#PLR): 17 #LIRT (#Horizons-#UDI-#PRV)|RE|EPP: 17 #EST (#EELV-#FaC)|G/EFA: 16 #RDSE (#PRG-#PRV-#PS-#Renaissance-#LFD13-#AC)|RE|S&D: 14 Non iscritti (#RN|ID, #Reconquête|NI): 4 Totale seggi: 348 Maggioranza: 175 @OsservatorioEsteri