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

Резултати

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

Пребарај: #gateiostartup

当前筛选 #gateiostartup清除筛选
Walken.io - Announcement

@walken_channel · Post #244 · 23.07.2022 г., 14:09

🤑Gate.io Startup Answer & Earn @walken_io💵 📝Take the quiz about Walken(WLKN) & Split a $3,000 mega prize!🏆 ⏰Ends at 9:00AM, Jul 25th (UTC) *How to participate: ✅ Join GateioOfficialNews and Walken community ✅Follow @Gateio_Startup & RT the 👉POST 🔛 Click 👉HERE to Participate now Learn More:https://www.gate.io/startup #Gateio#gateiostartup

BYIN Channel

@byinchan · Post #122 · 07.09.2024 г., 06:48

📣Startup Voting Campaign #4 - $8,000 up for grabs Vote for your favorite project by 6:00 AM, Sep 8 (UTC)! 🏆Winning projects will shine in the spotlight! 💎$BYIN$CEC$MAK$ANS 🔄Share to rally support for your pick! 👉Vote:https://gate.io/activities/startupvote?gt_disable_intercept_jump=1&now_period=5 #GateioStartup#Memecoins#Airdrop

BYIN Channel

@byinchan · Post #111 · 05.09.2024 г., 15:25

📣Day 3 of voting! $8,000 up for grabs—vote for your favorite project by 6:00 AM, Sep 8 (UTC)! 🏆Winning projects will shine in the spotlight! 💎$BYIN$CEC$MAK$ANS 🔁Share to rally support for your pick! 👉Vote:https://gate.io/activities/startupvote?gt_disable_intercept_jump=1&now_period=5 #GateioStartup#Memecoins#Airdrop

BYIN Channel

@byinchan · Post #106 · 04.09.2024 г., 09:48

🚀$8,000 up for grabs! #Vote for your favorite project by 06:00 AM, Sep 8 (UTC)! $BYIN$CEC$MAK$ANS 🏆Winning projects get the spotlight 🔁Retweet to support your pick Vote now:https://gate.io/activities/startupvote?gt_disable_intercept_jump=1&now_period=5 #GateioStartup#Memecoins#Airdrop

Holdcoin Channel

@Holdcoin_Channel · Post #309 · 11.12.2024 г., 12:59

📣Gate.io #StartupMining Initial Offering:HoldCoin (HOLD) ❇️Total Rewards: 73,333,333 $HOLD ❇️Estimated APR: 1241% 1⃣Stake $USDT & $GT from 01:00pm, Dec 11 (UTC) https://www.gate.io/startup-mining/HOLD?pid=111 2⃣Stake $HOLD and $GT from 01:00pm, Dec 16(UTC) https://www.gate.io/startup-mining/HOLD?pid=112 3⃣Stake $HOLD and $GT from 01:00pm, Dec 26(UTC) https://www.gate.io/startup-mining/HOLD?pid=113 📈Trading Starts: 13:00pm, Dec 16 (UTC) More:https://gate.io/announcements/article/41542 #Gateio#GateioStartup#Farming

Your Own Ads

@yourownads · Post #190 · 12.02.2025 г., 12:09

📈#Gateiopartner carnival: the main prize of $12,000 is being played out 🔥 The promotion is active until 11:00 Moscow time on February 24 ℹ️How to earn: 1) Registration on Gate + KYC2 2) Go here and click "Join now" 3) We complete the tasks: 🎁BONUS 1 : Registration + KYC, PrizeStartup voucher for 20 shares 🎁BONUS 2 : Make a deposit of $50, prize from $5 to $10 🎁BONUS 3 : Make a trading volume of $200, split the prize pool of $10,000 depending on the share in the total trading volume 🎁BONUS 4 : Invite users and share the prize pool of $2000 🔗Join now and earn: https://gate.io/fr/campaigns/396?ref=VLJMULHBVA #Gateio#GateioStartup#Crypto

Your Own Ads

@yourownads · Post #149 · 06.01.2025 г., 20:26

🚀Gate.io Startup Free Offering: Cat Gold Miner (CATGOLD) 🗓Subscription Period:06:00AM January 7 - January 9 (UTC) 💵Airdrop Amount: $50,000 CATGOLD 👉Sign up here 🔗 ⏰Trading Starts:10:00,AM January 9 (UTC) 📚Full Details:Click here 🎉Gate.io New Year Red Envelope: Get a $60 bonus by following this link ➜ Red Envelope ⚡️Don’t miss this unique chance to accelerate your earnings with CATGOLD! Places are limited, register now and be among the first to take advantage of this exclusive offer! ⭐️ 🔗gate.io 📈 #GateioStartup#Gateio#CATGOLD

Your Own Ads

@yourownads · Post #187 · 08.02.2025 г., 16:29

💰Trade $HQ on Gate.io & Win Your Share of $4,000! 👀 A new trading event is live on Gate.io, giving you the chance to earn big rewards! 🗓Event Period: February 7 at 06:00 AM UTC - February 12 at 06:00 AM UTC 💰Rewards: ✅$3,000 Trading Bonus – Trade at least $50 in HQ and share a $3,000 prize pool. ✅$950 New User Bonus – New users who sign up and trade $10 in HQ will receive $10 instantly. ✅$50 Lucky Reward – 1 lucky participant from the comments will win $50! ⚠️Important: ✔️ Complete your identity verification before the event ends to qualify. ✔️ Rewards will be distributed in HQ within 14 working days. ✔️ No multiple accounts or fraudulent activity allowed. 🔥Join now and start trading! Don’t miss your chance to win big! 🔗Sign up & start trading here: https://www.gate.io/signup/?ref_type=103 #Gateio#GateioStartup#StartupMining#Launchpool#Launchpad