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

Резултати

Пронајдени 7 слични објави

Пребарај: #remo

当前筛选 #remo清除筛选
Chollazo Exprés 🔥 Ofertas y Descuentos

@ChollazoExpres · Post #5673 · 09.01.2026 г., 19:30

💥Tabla de Remo Inflable ZLX 35 Pulgadas Diviértete en el agua con estilo y comodidad ✅OFERTA: 269.99€ ❌ Antes: 359.99€ 💰Ahorras un 25%🔥 Ideal para todos los niveles de habilidad, diseño estable y seguro 👉 Descubre la libertad de remar #remo#tabla#surf#deporte#descuentos#ofertas#invierno#rebajas 🛰️Oferta publicada en Deporte y Outdoor

AI match predictions

@ai_match_prediction · Post #11245 · 02.04.2026 г., 17:05

Brazil Serie A🇧🇷 2026-04-02 22:00 UTC Santos vs. Remo Predicted outcome: Santos✅ Predicted score: 2:0 Actual: Santos 2:0 #Santos#remo 2026-04-02 22:00 UTC Chapecoense-sc vs. Atletico-MG Predicted outcome: Chapecoense-sc❌ Predicted score: 2:1 Actual: Atletico-MG 0:4 #Chapecoensesc#AtleticoMG 2026-04-03 00:30 UTC Palmeiras vs. Gremio Predicted outcome: Palmeiras✅ Predicted score: 2:1 Actual: Palmeiras 2:1 #Palmeiras#Gremio 2026-04-03 00:30 UTC RB Bragantino vs. Flamengo Predicted outcome: Flamengo❌ Predicted score: 1:2 Actual: RB Bragantino 3:0 #RBBragantino#Flamengo #Football#BrazilSerieA

AI match predictions

@ai_match_prediction · Post #11745 · 25.04.2026 г., 17:05

Brazil Serie A🇧🇷 2026-04-25 21:30 UTC Bahia vs. Santos Predicted outcome: Bahia❌ Predicted score: 2:1 Actual: Draw 2:2 #Bahia#Santos 2026-04-25 21:30 UTC Botafogo vs. Internacional Predicted outcome: Botafogo❌ Predicted score: 2:1 Actual: Draw 2:2 #Botafogo#Internacional 2026-04-25 21:30 UTC Remo vs. Cruzeiro Predicted outcome: Cruzeiro✅ Predicted score: 0:1 Actual: Cruzeiro 0:1 #remo#Cruzeiro 2026-04-26 00:00 UTC Sao Paulo vs. Mirassol Predicted outcome: Sao Paulo✅ Predicted score: 2:1 Actual: Sao Paulo 1:0 #SaoPaulo#Mirassol #Football#BrazilSerieA

AI match predictions

@ai_match_prediction · Post #11864 · 02.05.2026 г., 13:05

Brazil Serie A🇧🇷 2026-05-02 19:00 UTC Botafogo vs. Remo Predicted outcome: Botafogo❌ Predicted score: 3:1 Actual: Remo 1:2 #Botafogo#remo 2026-05-02 21:30 UTC Palmeiras vs. Santos Predicted outcome: Palmeiras❌ Predicted score: 2:1 Actual: Draw 1:1 #Palmeiras#Santos 2026-05-02 21:30 UTC Vitoria vs. Coritiba Predicted outcome: Coritiba❌ Predicted score: 1:2 Actual: Vitoria 4:1 #Vitoria#Coritiba 2026-05-02 23:30 UTC Atletico Paranaense vs. Gremio Predicted outcome: Atletico Paranaense❌ Predicted score: 2:1 Actual: Draw 0:0 #AtleticoParanaense#Gremio 2026-05-03 00:00 UTC Cruzeiro vs. Atletico-MG Predicted outcome: Cruzeiro❌ Predicted score: 2:1 Actual: Atletico-MG 1:3 #Cruzeiro#AtleticoMG #Football#BrazilSerieA

AI match predictions

@ai_match_prediction · Post #11606 · 19.04.2026 г., 09:05

Brazil Serie A🇧🇷 2026-04-19 14:00 UTC Internacional vs. Mirassol Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Mirassol 1:2 #Internacional#Mirassol 2026-04-19 19:00 UTC Santos vs. Fluminense Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Fluminense 2:3 #Santos#Fluminense 2026-04-19 19:00 UTC Coritiba vs. Atletico-MG Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Coritiba 2:0 #Coritiba#AtleticoMG 2026-04-19 21:30 UTC Palmeiras vs. Atletico Paranaense Predicted outcome: Palmeiras✅ Predicted score: 2:1 Actual: Palmeiras 1:0 #Palmeiras#AtleticoParanaense 2026-04-19 21:30 UTC RB Bragantino vs. Remo Predicted outcome: RB Bragantino✅ Predicted score: 1:0 Actual: RB Bragantino 4:2 #RBBragantino#remo 2026-04-19 22:30 UTC Flamengo vs. Bahia Predicted outcome: Flamengo✅ Predicted score: 2:1 Actual: Flamengo 2:0 #Flamengo#Bahia #Football#BrazilSerieA

AI match predictions

@ai_match_prediction · Post #11328 · 05.04.2026 г., 13:05

Brazil Serie A🇧🇷 2026-04-05 19:00 UTC Chapecoense-sc vs. Vitoria Predicted outcome: Chapecoense-sc❌ Predicted score: 2:1 Actual: Draw 1:1 #Chapecoensesc#Vitoria 2026-04-05 20:30 UTC Flamengo vs. Santos Predicted outcome: Flamengo✅ Predicted score: 2:1 Actual: Flamengo 3:1 #Flamengo#Santos 2026-04-05 20:30 UTC Atletico-MG vs. Atletico Paranaense Predicted outcome: Atletico-MG✅ Predicted score: 2:1 Actual: Atletico-MG 2:1 #AtleticoMG#AtleticoParanaense 2026-04-05 22:30 UTC Bahia vs. Palmeiras Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Palmeiras 1:2 #Bahia#Palmeiras 2026-04-05 22:30 UTC Corinthians vs. Internacional Predicted outcome: Corinthians❌ Predicted score: 1:0 Actual: Internacional 0:1 #Corinthians#Internacional 2026-04-05 23:00 UTC Mirassol vs. RB Bragantino Predicted outcome: Mirassol❌ Predicted score: 2:1 Actual: RB Bragantino 0:1 #Mirassol#RBBragantino 2026-04-05 23:30 UTC Gremio vs. Remo Predicted outcome: Gremio❌ Predicted score: 2:0 Actual: Draw 0:0 #Gremio#remo #Football#BrazilSerieA

AI match predictions

@ai_match_prediction · Post #11159 · 22.03.2026 г., 13:05

Brazil Serie A🇧🇷 2026-03-22 19:00 UTC Vasco DA Gama vs. Gremio Predicted outcome: Vasco DA Gama✅ Predicted score: 2:1 Actual: Vasco DA Gama 2:1 #VascoDAGama#Gremio 2026-03-22 19:00 UTC Atletico Paranaense vs. Coritiba Predicted outcome: Coritiba❌ Predicted score: 1:2 Actual: Atletico Paranaense 2:0 #AtleticoParanaense#Coritiba 2026-03-22 19:00 UTC Cruzeiro vs. Santos Predicted outcome: Cruzeiro❌ Predicted score: 2:1 Actual: Draw 0:0 #Cruzeiro#Santos 2026-03-22 19:00 UTC remo vs. Bahia Predicted outcome: Bahia❌ Predicted score: 1:2 Actual: remo 4:1 #remo#Bahia 2026-03-22 21:30 UTC Internacional vs. Chapecoense-sc Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Internacional 2:0 #Internacional#Chapecoensesc 2026-03-22 21:30 UTC Vitoria vs. Mirassol Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Vitoria 1:0 #Vitoria#Mirassol 2026-03-22 23:30 UTC Corinthians vs. Flamengo Predicted outcome: Flamengo❌ Predicted score: 1:2 Actual: Draw 1:1 #Corinthians#Flamengo #Football#BrazilSerieA