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

Пребарај: #mantafc

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

@ai_match_prediction · Post #11794 · 27.04.2026 г., 17:05

Ecuador Liga Pro🇪🇨 2026-04-27 21:30 UTC Manta FC vs. Universidad Catolica Predicted outcome: Universidad Catolica❌ Predicted score: 1:2 Actual: Manta FC 1:0 #MantaFC#UniversidadCatolica 2026-04-28 00:00 UTC Aucas vs. Delfin SC Predicted outcome: Aucas✅ Predicted score: 1:0 Actual: Aucas 1:0 #Aucas#DelfinSC #Football#EcuadorLigaPro

AI match predictions

@ai_match_prediction · Post #11447 · 11.04.2026 г., 13:06

Ecuador Liga Pro🇪🇨 2026-04-11 19:00 UTC Mushuc Runa SC vs. Manta FC Predicted outcome: Mushuc Runa SC✅ Predicted score: 1:0 Actual: Mushuc Runa SC 1:0 #MushucRunaSC#MantaFC 2026-04-12 00:00 UTC Orense SC vs. Libertad Predicted outcome: Orense SC✅ Predicted score: 2:1 Actual: Orense SC 2:1 #OrenseSC#Libertad #Football#EcuadorLigaPro

AI match predictions

@ai_match_prediction · Post #11613 · 19.04.2026 г., 13:05

Ecuador Liga Pro🇪🇨 2026-04-19 18:00 UTC Manta FC vs. Deportivo Cuenca Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Deportivo Cuenca 0:1 #MantaFC#DeportivoCuenca 2026-04-19 20:30 UTC Independiente del Valle vs. LDU de Quito Predicted outcome: Independiente del Valle❌ Predicted score: 1:0 Actual: LDU de Quito 0:2 #IndependientedelValle#LDUdeQuito 🔥 PREMIUM PICK 🔥 2026-04-19 23:10 UTC Macara vs. Barcelona SC Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Macara 3:1 #Macara#BarcelonaSC #Football#EcuadorLigaPro

AI match predictions

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

Ecuador Liga Pro🇪🇨 2026-05-02 19:00 UTC Deportivo Cuenca vs. Tecnico Universitario Predicted outcome: Deportivo Cuenca✅ Predicted score: 2:1 Actual: Deportivo Cuenca 2:1 #DeportivoCuenca#TecnicoUniversitario 2026-05-02 21:30 UTC LDU de Quito vs. Guayaquil City FC Predicted outcome: LDU de Quito✅ Predicted score: 2:1 Actual: LDU de Quito 1:0 #LDUdeQuito#GuayaquilCityFC 2026-05-03 00:00 UTC Barcelona SC vs. Manta FC Predicted outcome: Barcelona SC❌ Predicted score: 2:0 Actual: Draw 1:1 #BarcelonaSC#MantaFC #Football#EcuadorLigaPro

AI match predictions

@ai_match_prediction · Post #11133 · 21.03.2026 г., 13:05

Ecuador Liga Pro🇪🇨 2026-03-21 19:00 UTC Delfin SC vs. Libertad Predicted outcome: Libertad❌ Predicted score: 0:1 Actual: Draw 0:0 #DelfinSC#Libertad 2026-03-21 21:30 UTC Deportivo Cuenca vs. Macara Predicted outcome: Draw✅ Predicted score: 1:1 Actual: Draw 1:1 #DeportivoCuenca#Macara 2026-03-22 00:00 UTC LDU de Quito vs. Manta FC Predicted outcome: LDU de Quito✅ Predicted score: 2:1 Actual: LDU de Quito 1:0 #LDUdeQuito#MantaFC #Football#EcuadorLigaPro

AI match predictions

@ai_match_prediction · Post #11332 · 05.04.2026 г., 13:06

Ecuador Liga Pro🇪🇨 🔥 PREMIUM PICK 🔥 2026-04-05 18:00 UTC Leones del Norte vs. Delfin SC Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Leones del Norte 1:0 #LeonesdelNorte#DelfinSC 2026-04-05 20:30 UTC Manta FC vs. Tecnico Universitario Predicted outcome: Manta FC❌ Predicted score: 1:0 Actual: Tecnico Universitario 0:2 #MantaFC#TecnicoUniversitario 2026-04-05 23:10 UTC Macara vs. Aucas Predicted outcome: Macara❌ Predicted score: 1:0 Actual: Aucas 0:1 #Macara#Aucas #Football#EcuadorLigaPro

AI match predictions

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

Ecuador Liga Pro🇪🇨 🔥 PREMIUM PICK 🔥 2026-04-22 16:00 UTC Leones del Norte vs. Manta FC Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Leones del Norte 3:0 #LeonesdelNorte#MantaFC 2026-04-22 18:00 UTC Delfin SC vs. Independiente del Valle Predicted outcome: Independiente del Valle✅ Predicted score: 1:2 Actual: Independiente del Valle 0:1 #DelfinSC#IndependientedelValle 2026-04-22 20:30 UTC Deportivo Cuenca vs. Orense SC Predicted outcome: Deportivo Cuenca❌ Predicted score: 2:1 Actual: Orense SC 1:3 #DeportivoCuenca#OrenseSC 2026-04-22 23:00 UTC Barcelona SC vs. Mushuc Runa SC Predicted outcome: Barcelona SC✅ Predicted score: 1:0 Actual: Barcelona SC 2:1 #BarcelonaSC#MushucRunaSC 2026-04-23 01:00 UTC LDU de Quito vs. Aucas Predicted outcome: LDU de Quito❌ Predicted score: 2:1 Actual: Draw 0:0 #LDUdeQuito#Aucas #Football#EcuadorLigaPro