Скорее всего уже слышали, что складывать строки через + это плохая практика. Падение производительности, и всё такое. Без лишних слов, давайте измерять:
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
⭐️#US30: Bulls Will Push Higher
It is essential that we apply multitimeframe technical analysis and there is no better example of why that is the case than the current 📈US30 chart which, if analyzed properly, clearly points in the upward direction.
#US30 SELL full Target done ☑️
Patience is a key 🔑 to success 🔥💰🤑🤑
Both Trade 700+Pips done 💯✅🚀🚀
VIP SIGNAL ON FIRE 🔥 always trust me guys and I will give you the best 💯.
Live Indices News Today – US30, NASDAQ, NAS100 & GER40 | March 23, 2026 https://www.fxpremiere.com/live-indices-news-today-us30-nasdaq-nas100-ger40-march-23-2026/#US30
🔅US30 Will Fall! Sell!📉
- - - - - - - -
Here is our detailed technical review for 📊US30.
The market is approaching a significant resistance area 49,454.8.
Due to the fact that we see a positive bearish reaction from the underlined area, I strongly believe that sellers will manage to push the price all the way down to 47,742.6 level.
- - - - - - - -
#freesignal#us30
- - - - - - - -
🌐Free Copy Trading: Link
📲Join VIP via Bot:Link
❓Official Contact:@signalprovidercontact
🔅US30 Is Bullish! Buy!📈
- - - - - - -
Here is our detailed technical review for 📊US30.
The market is testing a major horizontal structure 45,691.7.
Taking into consideration the structure & trend analysis, I believe that the market will reach 46,550.5 level soon.
- - - - - - - -
#freesignal#us30
- - - - - - - -
🌐Free Copy Trading: Link
📲Join VIP via Bot:Link
❓Official Contact:@signalprovidercontact
🔅US30 Will Grow! Long!📈
- - - - - - -
Here is our detailed technical review for 📊US30.
The market is trading around a solid horizontal structure 48,884.2.
The above observations make me that the market will inevitably achieve 49,692.2 level.
- - - - - - - -
#freesignal#us30
- - - - - - - -
🌐Free Copy Trading: Link
📲Join VIP via Bot:Link
❓Official Contact:@signalprovidercontact
🔅US30 Is Very Bearish! Short!📉
- - - - - - - -
Here is our detailed technical review for 📊US30.
The market is trading around a solid horizontal structure 50,088.7.
The above observations make me that the market will inevitably achieve 49,623.5 level.
- - - - - - - -
#freesignal#us30
- - - - - - - -
🌐Free Copy Trading: Link
📲Join VIP via Bot:Link
❓Official Contact:@signalprovidercontact
🔅US30 Will Move Lower! Sell!📉
- - - - - - - -
Take a look at our analysis for 📊US30.
The market is approaching a significant resistance area 49,481.0.
Due to the fact that we see a positive bearish reaction from the underlined area, I strongly believe that sellers will manage to push the price all the way down to 49,076.8 level.
- - - - - - - -
#freesignal#us30
- - - - - - - -
🌐Free Copy Trading: Link
📲Join VIP via Bot:Link
❓Official Contact:@signalprovidercontact
🔅US30 Is Bearish! Sell!📉
- - - - - - - -
Here is our detailed technical review for 📊US30.
The market is on a crucial zone of supply 49,331.6.
The above-mentioned technicals clearly indicate the dominance of sellers on the market. I recommend shorting the instrument, aiming at 48,745.5 level.
- - - - - - - -
#freesignal#us30
- - - - - - - -
🌐Free Copy Trading: Link
📲Join VIP via Bot:Link
❓Official Contact:@signalprovidercontact