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

Пребарај: #lokomotiv

当前筛选 #lokomotiv清除筛选
AI match predictions

@ai_match_prediction · Post #11826 · 01.05.2026 г., 13:05

Russia Premier League🇷🇺 2026-05-01 14:00 UTC Krylia Sovetov vs. Spartak Moscow Predicted outcome: Spartak Moscow❌ Predicted score: 2:3 Actual: Krylia Sovetov 2:1 #KryliaSovetov#SpartakMoscow 2026-05-01 16:30 UTC Lokomotiv vs. Dynamo Predicted outcome: Lokomotiv❌ Predicted score: 3:2 Actual: Draw 1:1 #Lokomotiv#DynamoMoscow #Football#RussiaPremierLeague

AI match predictions

@ai_match_prediction · Post #11718 · 25.04.2026 г., 05:05

Russia Premier League🇷🇺 🔥 PREMIUM PICK 🔥 2026-04-25 11:30 UTC FC Rostov vs. FC Orenburg Predicted outcome: Draw❌ Predicted score: 1:1 Actual: FC Orenburg 0:1 #Rostov#Orenburg 2026-04-25 14:00 UTC Krylia Sovetov vs. Lokomotiv Predicted outcome: Lokomotiv❌ Predicted score: 1:2 Actual: Krylia Sovetov 2:0 #KryliaSovetov#Lokomotiv 2026-04-25 16:30 UTC Rubin vs. CSKA Moscow Predicted outcome: Rubin❌ Predicted score: 1:0 Actual: Draw 0:0 #Rubin#CSKA #Football#RussiaPremierLeague

AI match predictions

@ai_match_prediction · Post #11658 · 22.04.2026 г., 09:05

Russia Premier League🇷🇺 2026-04-22 14:30 UTC FC Orenburg vs. Nizhny Novgorod Predicted outcome: Draw❌ Predicted score: 1:1 Actual: FC Orenburg 2:1 #Orenburg#NizhnyNovgorod 2026-04-22 16:45 UTC Lokomotiv vs. Zenit Predicted outcome: Zenit❌ Predicted score: 1:2 Actual: Draw 0:0 #Lokomotiv#Zenit 2026-04-22 16:45 UTC Dynamo vs. Rubin Predicted outcome: Dynamo❌ Predicted score: 2:1 Actual: Rubin 0:1 #DynamoMoscow#Rubin #Football#RussiaPremierLeague

AI match predictions

@ai_match_prediction · Post #11311 · 05.04.2026 г., 05:05

Russia Premier League🇷🇺 2026-04-05 11:00 UTC Nizhny Novgorod vs. FC Rostov Predicted outcome: Draw❌ Predicted score: 1:1 Actual: FC Rostov 0:1 #NizhnyNovgorod#Rostov 🔥 PREMIUM PICK 🔥 2026-04-05 13:30 UTC Dinamo Makhachkala vs. Baltika Predicted outcome: Baltika❌ Predicted score: 0:1 Actual: Draw 2:2 #DinamoMakhachkala#Baltika 2026-04-05 16:30 UTC Spartak Moscow vs. Lokomotiv Predicted outcome: Spartak Moscow✅ Predicted score: 2:1 Actual: Spartak Moscow 2:1 #SpartakMoscow#Lokomotiv #Football#RussiaPremierLeague

AI match predictions

@ai_match_prediction · Post #12007 · 10.05.2026 г., 05:05

Russia Premier League🇷🇺 2026-05-10 09:30 UTC FC Orenburg vs. Krylia Sovetov Predicted outcome: FC Orenburg✅ Predicted score: 2:1 Actual: FC Orenburg 1:0 #Orenburg#KryliaSovetov 2026-05-10 12:00 UTC Zenit vs. FC Sochi Predicted outcome: Zenit✅ Predicted score: 3:0 Actual: Zenit 2:1 #Zenit#FCSochi 2026-05-10 14:15 UTC Akhmat vs. Dinamo Makhachkala Predicted outcome: Akhmat❌ Predicted score: 2:1 Actual: Draw 1:1 #Akhmat#DinamoMakhachkala 2026-05-10 16:30 UTC Lokomotiv vs. Baltika Predicted outcome: Baltika❌ Predicted score: 1:2 Actual: Lokomotiv 1:0 #Lokomotiv#Baltika #Football#RussiaPremierLeague

AI match predictions

@ai_match_prediction · Post #11556 · 18.04.2026 г., 01:05

Russia Premier League🇷🇺 2026-04-18 09:00 UTC FC Orenburg vs. Lokomotiv Predicted outcome: Draw❌ Predicted score: 2:2 Actual: Lokomotiv 0:1 #Orenburg#Lokomotiv 2026-04-18 11:30 UTC Krylia Sovetov vs. CSKA Moscow Predicted outcome: Draw✅ Predicted score: 1:1 Actual: Draw 1:1 #KryliaSovetov#CSKA 2026-04-18 14:00 UTC Rubin vs. Akron Predicted outcome: Rubin❌ Predicted score: 2:1 Actual: Draw 1:1 #Rubin#Akron 2026-04-18 16:30 UTC Nizhny Novgorod vs. Dynamo Predicted outcome: Dynamo❌ Predicted score: 1:2 Actual: Draw 1:1 #NizhnyNovgorod#DynamoMoscow #Football#RussiaPremierLeague

AI match predictions

@ai_match_prediction · Post #11457 · 12.04.2026 г., 05:05

Russia Premier League🇷🇺 2026-04-12 11:00 UTC CSKA Moscow vs. FC Sochi Predicted outcome: CSKA Moscow❌ Predicted score: 3:1 Actual: FC Sochi 0:1 #CSKA#FCSochi 2026-04-12 13:30 UTC Lokomotiv vs. Dinamo Makhachkala Predicted outcome: Lokomotiv❌ Predicted score: 3:1 Actual: Draw 1:1 #Lokomotiv#DinamoMakhachkala 2026-04-12 13:30 UTC FC Rostov vs. Spartak Moscow Predicted outcome: Draw✅ Predicted score: 1:1 Actual: Draw 1:1 #Rostov#SpartakMoscow 2026-04-12 16:30 UTC Zenit vs. FC Krasnodar Predicted outcome: Zenit❌ Predicted score: 1:0 Actual: Draw 1:1 #Zenit#Krasnodar #Football#RussiaPremierLeague

AI match predictions

@ai_match_prediction · Post #11141 · 22.03.2026 г., 05:05

Russia Premier League🇷🇺 2026-03-22 10:45 UTC FC Orenburg vs. Spartak Moscow Predicted outcome: Draw❌ Predicted score: 2:2 Actual: Spartak Moscow 0:2 #Orenburg#SpartakMoscow 2026-03-22 13:00 UTC Dynamo vs. Zenit Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Zenit 1:3 #DynamoMoscow#Zenit 2026-03-22 13:30 UTC Krylia Sovetov vs. Rubin Predicted outcome: Draw✅ Predicted score: 1:1 Actual: Draw 0:0 #KryliaSovetov#Rubin 2026-03-22 16:00 UTC Lokomotiv vs. Akron Predicted outcome: Lokomotiv✅ Predicted score: 2:1 Actual: Lokomotiv 5:1 #Lokomotiv#Akron #Football#RussiaPremierLeague