Скорее всего уже слышали, что складывать строки через + это плохая практика. Падение производительности, и всё такое. Без лишних слов, давайте измерять:
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
🔥NEW RELEASE🔥
😁P.E.D. Footlock system: Leg locks on Steroids by Dima Murovanni😁
➡️Unlock the full potential of your leg lock game with the P.E.D. Footlock System, a groundbreaking instructional by B-Team's own Dima Murovanni.
➡️Dima breaks down why the straight footlock should be the foundation of your leg lock system—showing how its mechanics, control positions, and finishing pathways translate into heel hooks, kneebars, inside sankaku, and more..
̶$̶1̶2̶7̶😍$14.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#DimaMurovanni#Leglocks#NoGi#BTeam
💁♀️Buy
💁♀️
😁Samurai Foot Sweeps & Leg Trips By Kenta Iwamoto😁
➡️Unlock the ancient foot-sweeping secrets of Japan’s samurai-era martial arts, updated for the modern mats.
➡️These are not just traditional techniques – they are refined, competition-tested entries, setups, and finishes that blend seamlessly with modern BJJ and no-gi grappling. Whether you’re looking to score in IBJJF rulesets or develop a takedown game that feels effortless, Kenta delivers the details that make the difference.
➡️In Samurai Foot Sweeps &Leg Trips, Kenta Iwamoto – a judo black belt and high-level BJJ competitor – pulls back the curtain on a hidden arsenal of off-balancing attacks that have been quietly dominating in Japan for generations.
$99😍$9.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#KentaIwamoto#Takedowns#NoGi#BTeam
💁♀️Buy
💁♀️
🔥NEW RELEASE🔥
😁Octopus Guard 2.0 by Craig Jones😁
➡️In this updated course, Craig Jones refines the original framework with cleaner entries, stronger off-balancing, and smoother transitions to the back, legs, and top position
➡️Built specifically for modern no-gi grappling, this system thrives against aggressive passers who want to stay on their feet and smash forward.
$197😍$19.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
👑MasterClass
✈️@bjjfanaticsinstructionals
#CraigJones#Guard#NoGi#BTeam
💁♀️Buy
💁♀️
😁The White Monster Method by Declan Moody😁
➡️Discover a brutal, pressure-based passing system that forces your opponents into discomfort and drains their energy.
➡️In The White Monster Method, BJJ competitor Declan Moody teaches his signature north-south passing approach — built around control, weight distribution, and calculated movement that makes your opponents carry your body and burn out fast.
$79😍$9.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#DeclanMoody#Passing#NoGi#BTeam
💁♀️Buy
💁♀️
😁Ninja Escapes by Kenta Iwamoto😁
➡️Unlock the secrets to flawless back escapes and turtle escapes with Ninja Escapes by Kenta Iwamoto — a masterful Brazilian Jiu-Jitsu instructional series designed to elevate your defensive game
➡️Whether you find yourself trapped in a tight back control or stuck in the turtle position, this detailed program breaks down escape techniques with precision and clarity.
̶$̶7̶9̶😍$9.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#KentaIwamoto#Escapes#NoGi#BTeam
💁♀️Buy
💁♀️
🔥NEW RELEASE🔥
😁Under the Legs Passing Anthology by Lachlan Giles😁
➡️Master The Most Battle-Tested Guard Passing System For Beating Modern Guards – Including K-Guard, Inversions, & Leg Lock Hunters – With Lachlan Giles’ Step-By-Step Under-The-Legs Passing Blueprint
➡️This anthology breaks down every major variation of under-the-legs passing – including the double under, over-under, single under, and single under with knee pin – and shows you how to blend them together into a cohesive, unstoppable passing game.
$197😍$19.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
👑MasterClass
✈️@bjjfanaticsinstructionals
#LachlanGiles#Passing#Gi#BTeam
💁♀️Buy
💁♀️
👨💻The Nicky Ryan Blueprint
Content now available ⚠️
Updating as he releases new content
Nicky Ryan - The Nicky Ryan Blueprint
🚟
🚟
🚟
🚟
🚟
🚟
🚟
🚟
🚟
🚟
💬BjjFanatics Instructionals
Remember to always recommend the channel ✅
#NickyRyan#NoGi#Technique#BTeam#CraigJones