Скорее всего уже слышали, что складывать строки через + это плохая практика. Падение производительности, и всё такое. Без лишних слов, давайте измерять:
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
🔥「0」Gas $U Transfers on BNBCHAIN with TokenPocket!
TokenPocket now enables transferring $U with 0 gas fee on the BNB Chain automatically - enjoy smooth, 0-gas transfers, all with a secure, wallet-native experience.
Your first choice of #StablecoinWallet
👉http://tp.xyz
https://x.com/TokenPocket_TP/status/2003755846489231701?s=20
🆕$U is now listed on TokenPocket!
Manage your $U seamlessly with TokenPocket_TP: store, send, and swap in one powerful multi-chain #StablecoinWallet.
Track Easier! Trade Smarter!
👉http://tp.xyz
🟦 TokenPocket Weekly Report 🟦
🔵 Supported $U on TokenPocket.
🔵 Embrace New Era of #StablecoinWallet
🔵 Notice of Wallet Service Upgrade
🔵 Listed 5 DApps.
All-in-one, all in TokenPocket 👉http://tp.xyz
🚀TokenPocket Now Supports Multi-Chain Gas Payment with Stablecoins!
Powered by EIP-7702, TokenPocket now enables transferring gas payments in $USDT, $USDC, and more across multi-chains — including BNBCHAIN, base, and arbitrum — for a smoother, more cost-efficient transfer experience.
🔥 Explore it now in #StablecoinWallet!
🔗Tutorial
🧊Be Your First #StablecoinWallet!
→ https://help.tokenpocket.pro/en/wallet-operation/stablecoin/wallet
✅ Self-custody, your keys, your coins!
✅ Multichain supported — one wallet, all chains!
✅ Gas-free stablecoin transfers on BNBChain & Tron (more coming!)
🔐 Powered by TokenPocket — simple, secure, seamless.
📝 TokenPocket Monthly Report — June 2025
📖 Read the full report: https://tokenpocket-gm.medium.com/tokenpocket-monthly-report-june-2025-8a642e365b94
Main Upgrade ⏬
🎯#StablecoinWallet
🎯 Market Chart Upgraded
🎯 Gas-Free Transfer on TRON and BNBChain
🎯 Security Enhancement: Now supporting native MultiSig wallets for Bitcoin and Core — giving your assets even stronger protection.
✍️Share your thoughts and suggestions through our survey for a chance to win exclusive prizes. Every piece of feedback is valued!
✍️ Fill out the Q&A⏬
https://docs.google.com/forms/d/e/1FAIpQLSe8tElYK6V6qN5MqDtDIj7G7SjUw3cSv3bwC-rSXyLVq2USRQ/viewform?usp=send_form
📍 All In One, All In TokenPocket!
🔗https://tp.xyz
🔥USDT Supply on the TRON Surpasses $80 Billion, now accounting for over 51.74% of global circulation, making TRON the leading stablecoin network.
TokenPocket plays a key role by helping users save on gas through innovations like USDT gas payments, one-click energy rentals, and daily subsidy programs.
In 2025, TokenPocket continues to scale stablecoin usability — reinforcing its position as the go-to #StablecoinWallet for global users!
https://x.com/TokenPocket_TP/status/1936994956620750933
🎁 Pay Gas with Stablecoins & Share a Price Pool of $2,000
→https://zealy.io/cw/tokenpocket/questboard/sprints
🚀 New round of #StablecoinWallet Campaign is now live on zealy — complete quests and experience paying gas fees with stablecoins via TokenPocket.
*Exclusively for the community. No investment advice! Any new quests will be announced in our Telegram community first.💕💕#NFA
📝 TokenPocket Monthly Report — January 2026
In January, TokenPocket focused on stablecoins, security enhancement and trading experience.
🎯#SAFU
TokenPocket now supports Solana Multi-Sig Wallet with native integration. Multi-Sig, Multi- Safe.
🎯 Advanced Trading Experience
TokenPocket has expanded Limit Order support to
Ethereum, Base, BNB Chain, Arbitrum, and Polygon. With limit orders, users can define their target prices in advance and execute with more discipline. Better execution quality with less time spent watching charts.
🎯#StablecoinWallet
TokenPocket now supports stablecoin gas payment on
Base, BNB Chain, Polygon, Arbitrum, and Ethereum, and this capability is also available in Swap & Bridge. That means users can pay network fees with stablecoins in more scenarios, reducing reliance on native gas tokens and making transfers, swaps, and bridging much smoother.
📍 All In One, All in TokenPocket
https://tokenpocket-gm.medium.com/tokenpocket-monthly-report-january-2026-2c48e070338e
🚀 Keep Enjoying BNBCHAIN Gas-Free Stablecoin Transfers with TokenPocket!
✅ Supports $USDC & #USD1 - Ends on Nov 30, 2025.
( $USDT Support Ended on Oct 31, 2025)
🔷 Perfect for daily transfers with user-friendly interface.
Unlock the future of #StablecoinWallet with TokenPocket.
👉http://tp.xyz
🎉 Enjoy Gas-Free Stablecoin Transfers on BNBCHAIN with TokenPocket.
✅Supports $USDT & #USD1 - Ended on July 31
🔷Perfect for new users & everyday transfers.
Transfer smarter with your #StablecoinWallet!
👉https://tp.xyz