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

Резултати

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

Пребарај: #albionfc

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

@ai_match_prediction · Post #11146 · 22.03.2026 г., 05:06

Uruguay Primera División - Apertura🇺🇾 2026-03-22 13:00 UTC Juventud vs. Albion FC Predicted outcome: Juventud❌ Predicted score: 2:1 Actual: Albion FC 0:1 #Juventud#AlbionFC 2026-03-22 19:00 UTC Progreso vs. Boston River Predicted outcome: Progreso❌ Predicted score: 1:0 Actual: Boston River 0:1 #Progreso#BostonRiver #Football#UruguayPrimeraDivisión

AI match predictions

@ai_match_prediction · Post #11411 · 10.04.2026 г., 17:05

Uruguay Primera División - Apertura🇺🇾 2026-04-10 23:00 UTC Cerro Largo vs. Cerro Predicted outcome: Cerro Largo❌ Predicted score: 1:0 Actual: Draw 1:1 #CerroLargo#Cerro 2026-04-11 13:00 UTC Atletico Torque vs. Albion FC Predicted outcome: Atletico Torque❌ Predicted score: 2:1 Actual: Albion FC 0:1 #AtleticoTorque#AlbionFC #Football#UruguayPrimeraDivisión

AI match predictions

@ai_match_prediction · Post #11994 · 09.05.2026 г., 13:05

Uruguay Primera División - Apertura🇺🇾 2026-05-09 18:30 UTC Danubio vs. Albion FC Predicted outcome: Danubio❌ Predicted score: 2:1 Actual: Albion FC 0:1 #Danubio#AlbionFC 2026-05-09 21:30 UTC Central Espanol vs. Racing Montevideo Predicted outcome: Racing Montevideo❌ Predicted score: 1:2 Actual: Central Espanol 2:0 #CentralEspanol#RacingMontevideo #Football#UruguayPrimeraDivisión

AI match predictions

@ai_match_prediction · Post #11229 · 31.03.2026 г., 09:05

Uruguay Primera División - Apertura🇺🇾 2026-03-31 14:00 UTC Progreso vs. Liverpool Montevideo Predicted outcome: Draw✅ Predicted score: 1:1 Actual: Draw 3:3 #Progreso#LiverpoolMontevideo 2026-03-31 22:00 UTC Defensor Sporting vs. Albion FC Predicted outcome: Defensor Sporting❌ Predicted score: 1:0 Actual: Draw 1:1 #DefensorSporting#AlbionFC #Football#UruguayPrimeraDivisión

AI match predictions

@ai_match_prediction · Post #11179 · 25.03.2026 г., 09:05

Uruguay Primera División - Apertura🇺🇾 2026-03-25 17:00 UTC Albion FC vs. Wanderers Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Albion FC 2:1 #AlbionFC#Wanderers 2026-03-25 20:00 UTC Cerro vs. Juventud Predicted outcome: Juventud❌ Predicted score: 0:1 Actual: Cerro 1:0 #Cerro#Juventud 2026-03-25 23:30 UTC Boston River vs. Penarol Predicted outcome: Penarol✅ Predicted score: 0:1 Actual: Penarol 0:2 #BostonRiver#Penarol #Football#UruguayPrimeraDivisión

AI match predictions

@ai_match_prediction · Post #11733 · 25.04.2026 г., 09:06

Uruguay Primera División - Apertura🇺🇾 2026-04-25 15:00 UTC Juventud vs. Liverpool Montevideo Predicted outcome: Draw✅ Predicted score: 1:1 Actual: Draw 1:1 #Juventud#LiverpoolMontevideo 2026-04-25 18:30 UTC Deportivo Maldonado vs. Albion FC Predicted outcome: Deportivo Maldonado❌ Predicted score: 2:1 Actual: Albion FC 1:2 #DeportivoMaldonado#AlbionFC 2026-04-25 22:00 UTC Club Nacional vs. Danubio Predicted outcome: Club Nacional❌ Predicted score: 2:1 Actual: Danubio 1:2 #ClubNacional#Danubio #Football#UruguayPrimeraDivisión

AI match predictions

@ai_match_prediction · Post #11318 · 05.04.2026 г., 05:06

Uruguay Primera División - Apertura🇺🇾 2026-04-05 13:00 UTC Albion FC vs. Cerro Largo Predicted outcome: Albion FC❌ Predicted score: 1:0 Actual: Draw 2:2 #AlbionFC#CerroLargo 2026-04-05 18:30 UTC Cerro vs. Defensor Sporting Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Cerro 1:0 #Cerro#DefensorSporting 2026-04-05 21:30 UTC Liverpool Montevideo vs. Deportivo Maldonado Predicted outcome: Draw❌ Predicted score: 2:2 Actual: Deportivo Maldonado 0:2 #LiverpoolMontevideo#DeportivoMaldonado #Football#UruguayPrimeraDivisión

AI match predictions

@ai_match_prediction · Post #11884 · 03.05.2026 г., 05:07

Uruguay Primera División - Apertura🇺🇾 2026-05-03 12:30 UTC Progreso vs. Cerro Largo Predicted outcome: Progreso❌ Predicted score: 2:1 Actual: Cerro Largo 0:1 #Progreso#CerroLargo 2026-05-03 15:00 UTC Boston River vs. Central Espanol Predicted outcome: Boston River✅ Predicted score: 2:1 Actual: Boston River 2:1 #BostonRiver#CentralEspanol 2026-05-03 18:30 UTC Racing Montevideo vs. Atletico Torque Predicted outcome: Racing Montevideo❌ Predicted score: 2:1 Actual: Draw 1:1 #RacingMontevideo#AtleticoTorque 2026-05-03 23:00 UTC Albion FC vs. Club Nacional Predicted outcome: Albion FC✅ Predicted score: 2:1 Actual: Albion FC 3:2 #AlbionFC#ClubNacional #Football#UruguayPrimeraDivisión