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

Резултати

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

Пребарај: #hold

当前筛选 #hold清除筛选
Holdcoin Channel

@Holdcoin_Channel · Post #261 · 09.10.2024 г., 09:03

💎#HoldCoin is taking the world by storm! 🔥 Major media outlets like Cryptoate, Cryptomanias, Geekocoin, Digital Journal, and Benzinga have all reported on HoldCoin. 💎 Does this mean some big events are just around the corner? 🐂 Keep holding #Hold! Follow our channel and X to get the latest updates on the TGE as soon as they drop! 🚀

Holdcoin Channel

@Holdcoin_Channel · Post #350 · 20.12.2024 г., 07:47

🎉HoldCoin Avatar Challenge is ON! 🎉 🚀 Update your avatar with the exclusive HoldCoin badge in TokenSpritz_bot and WIN big! 🖥Event Duration: Dec 20 – Dec 27 💰Prize Pool: $500 USDT in $HOLD! 🔑How to Join: 1️⃣ Go to TokenSpritz_bot and update your avatar with the HoldCoin badge. 2️⃣ Contact the admin for verification in the HoldCoin community: @martian_0x 3️⃣ Rewards will be sent at the end of the event! 🔥 Don’t miss your chance to shine and earn $HOLD rewards! 🏆 👉 Join now:@Holdcoin_Group #Web3#Crypto#HOLD#Airdrops#TON

Holdcoin Channel

@Holdcoin_Channel · Post #333 · 16.12.2024 г., 13:48

🚀 $HOLD/USDT Futures Will Be Listed on 13:15, December 16 (UTC) on #MEXC - Offering Adjustable Leverage of Up to 50x! More Info👇 https://www.mexc.com/support/articles/17827791520467 #HOLD#MEXCFutures

🤩Fintopio is a new non-custodial wallet in the TON ecosystem #Fintopio is a cryptocurrency wallet in🪙 Telegram, which can be used via mini app and website. With its help, you can conveniently use #DeFi and #CeFi functions, pay bills, divide expenses, buy goods and transfer money without leaving the application. To get started quickly, you can import an existing wallet: 🟡Open "DeFi" tab in the Fintopio app 🟡 Click "View all" 🟡 Next – “Import wallet” 🟡 Enter your 12-word secret phrase to import your wallet 👛Currently the wallet supports: #BTC, #USDT [#ERC20/#TRC20], #ETH, #TRX and #TON. 📲 The project has a game to attract an audience where $HP (Hold Points) are farmed. You need to collect coins every 8 hours and in the future you can exchange them for the main utility token of Fintopio named $HOLD. The token is only available to early participants of the project, the more you #HOLD, the more rewards you will receive from Fintopio. So it's better to start right now!🚀 Game | Channel | Website

X

@PROJECT · Post #32 · 25.12.2024 г., 21:58

🚀 Grab #CDB#Tokens NOW Before They Hit $0.015 in Jan 2025! ⏳ Only a Few Days Left! #Stake, #hold, & prepare for #BIG profits with the $0.020 listing #coming in Feb 2025! 💥 Don’t Miss Out—Act #Fast! 🔗https://cloudatabox.com/register?ref_code=6515554&pos=right #CDBToken#CryptoProfits#StakeAndEarn#Cloudatabox