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

Пребарај: #referrals

当前筛选 #referrals清除筛选
BLC Market - mini-app BulCoin

@bulcoin_blc · Post #338 · 16.04.2026 г., 10:00

Now is the best time to enter BLC Market. Early stage project: - actively forming structure - interfaces are being published - new mechanics are opening up If you're already here - you're getting in ahead of most. Scaling will follow next. #community#referrals FAQ | BUY

🏆 Premium, NFT, Tokens

@Giiveaways · Post #2171 · 18.06.2024 г., 16:00

👥 The system of inviting friends to CITY Holder! 🏠🐹 With the invitation system you get in-game income not only for inviting friends, but also for their further development! The better your buddy's results, the higher your income. Combine strategies and show incredible results! #CITYHolder#Referrals https://t.me/cityholder🆕👈 °°°°°°

BLC Market - mini-app BulCoin

@bulcoin_blc · Post #278 · 07.03.2026 г., 12:00

Launching the BulCoin Referral Program We are starting a referral program for the early BulCoin community. Now every participant can invite friends to the project and receive additional bonuses. How it works: Invite your friends to the BulCoin channel Ask them to mention your username in the comments to this post Bonuses BLC are credited for invitations Rewards: • 3 invited — You join the private Pioneers chat • 10 invited — Bonus of 500,000 BLC • 25 invited — 3mln BLC + Participation in the BulCoin operational staff We will regularly publish the leaderboard — participants who have invited the most people. The best participants can receive additional rewards and a special status in the community. This is just the beginning of the formation of the BulCoin Early Community Invite your friends and help build the BulCoin community #Pioneers#Referrals FAQ | BUY

BLC Market - mini-app BulCoin

@bulcoin_blc · Post #336 · 12.04.2026 г., 10:00

Invitation mechanics in BLC Market There will be a separate section in the app through which you can invite new users. This will allow: — community to grow faster — build connections between members — increase activity within the platform We will show the interface in the upcoming updates. #profile#community#referrals FAQ | BUY

SingSing Announcement

@singsingchannel · Post #935 · 27.10.2024 г., 06:52

🎉 Invite Reward Boost! 🎉 Invite friends to join SingSing and earn 20 $KARA FREE for each successful invite (up from 10 $KARA)! 🔥 👥 The more, the merrier – stack up your $KARA effortlessly! 💸 Start inviting now and claim your rewards! #SingSing#KARA#Invite#Referrals 🎤Announcement | Chat | X (Twitter) | Website | Game