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

Резултати

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

Пребарај: #angers

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

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

France Ligue 1🇫🇷 2026-04-25 13:00 UTC Lyon vs. Auxerre Predicted outcome: Lyon✅ Predicted score: 1:0 Actual: Lyon 3:2 #Lyon#Auxerre 2026-04-25 17:00 UTC Angers vs. Paris Saint Germain Predicted outcome: Paris Saint Germain✅ Predicted score: 1:2 Actual: Paris Saint Germain 0:3 #Angers#PSG 2026-04-25 19:05 UTC Toulouse vs. Monaco Predicted outcome: Monaco❌ Predicted score: 1:2 Actual: Draw 2:2 #Toulouse#Monaco #Football#FranceLigue1

AI match predictions

@ai_match_prediction · Post #11568 · 18.04.2026 г., 09:05

France Ligue 1🇫🇷 2026-04-18 15:00 UTC Lorient vs. Marseille Predicted outcome: Draw❌ Predicted score: 2:2 Actual: Lorient 2:0 #Lorient#Marseille 2026-04-18 17:00 UTC Angers vs. Le Havre Predicted outcome: Draw✅ Predicted score: 1:1 Actual: Draw 1:1 #Angers#LEHavre 2026-04-18 19:05 UTC Lille vs. Nice Predicted outcome: Lille❌ Predicted score: 2:1 Actual: Draw 0:0 #Lille#Nice #Football#FranceLigue1

AI match predictions

@ai_match_prediction · Post #11875 · 03.05.2026 г., 05:05

France Ligue 1🇫🇷 2026-05-03 13:00 UTC Lille vs. Le Havre Predicted outcome: Lille❌ Predicted score: 1:0 Actual: Draw 1:1 #Lille#LEHavre 2026-05-03 15:15 UTC Strasbourg vs. Toulouse Predicted outcome: Strasbourg❌ Predicted score: 2:1 Actual: Toulouse 1:2 #Strasbourg#Toulouse 2026-05-03 15:15 UTC Auxerre vs. Angers Predicted outcome: Auxerre✅ Predicted score: 2:1 Actual: Auxerre 3:1 #Auxerre#Angers 2026-05-03 15:15 UTC Paris FC vs. Stade Brestois 29 Predicted outcome: Paris FC✅ Predicted score: 2:1 Actual: Paris FC 4:0 #ParisFC#StadeBrestois29 2026-05-03 18:45 UTC Lyon vs. Rennes Predicted outcome: Lyon✅ Predicted score: 3:2 Actual: Lyon 4:2 #Lyon#Rennes #Football#FranceLigue1

AI match predictions

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

France Ligue 1🇫🇷 2026-04-05 13:00 UTC Angers vs. Lyon Predicted outcome: Lyon❌ Predicted score: 1:2 Actual: Draw 0:0 #Angers#Lyon 2026-04-05 15:15 UTC Lorient vs. Paris FC Predicted outcome: Lorient❌ Predicted score: 2:1 Actual: Draw 1:1 #Lorient#ParisFC 2026-04-05 15:15 UTC Le Havre vs. Auxerre Predicted outcome: Draw✅ Predicted score: 1:1 Actual: Draw 1:1 #LEHavre#Auxerre 2026-04-05 15:15 UTC Metz vs. Nantes Predicted outcome: Draw✅ Predicted score: 2:2 Actual: Draw 0:0 #Metz#Nantes 2026-04-05 18:45 UTC Monaco vs. Marseille Predicted outcome: Monaco✅ Predicted score: 2:1 Actual: Monaco 2:1 #Monaco#Marseille #Football#FranceLigue1

AI match predictions

@ai_match_prediction · Post #12027 · 10.05.2026 г., 13:05

France Ligue 1🇫🇷 2026-05-10 19:00 UTC Angers vs. Strasbourg Predicted outcome: Strasbourg❌ Predicted score: 1:2 Actual: Draw 1:1 #Angers#Strasbourg 2026-05-10 19:00 UTC Paris Saint Germain vs. Stade Brestois 29 Predicted outcome: Paris Saint Germain✅ Predicted score: 3:1 Actual: Paris Saint Germain 1:0 #PSG#StadeBrestois29 2026-05-10 19:00 UTC Monaco vs. Lille Predicted outcome: Lille✅ Predicted score: 1:2 Actual: Lille 0:1 #Monaco#Lille 2026-05-10 19:00 UTC Rennes vs. Paris FC Predicted outcome: Rennes✅ Predicted score: 2:1 Actual: Rennes 2:1 #Rennes#ParisFC 2026-05-10 19:00 UTC Toulouse vs. Lyon Predicted outcome: Lyon❌ Predicted score: 1:2 Actual: Toulouse 2:1 #Toulouse#Lyon 2026-05-10 19:00 UTC Auxerre vs. Nice Predicted outcome: Auxerre✅ Predicted score: 2:1 Actual: Auxerre 2:1 #Auxerre#Nice 2026-05-10 19:00 UTC Le Havre vs. Marseille Predicted outcome: Le Havre❌ Predicted score: 2:1 Actual: Marseille 0:1 #LEHavre#Marseille 2026-05-10 19:00 UTC Metz vs. Lorient Predicted outcome: Lorient✅ Predicted score: 1:2 Actual: Lorient 0:4 #Metz#Lorient #Football#FranceLigue1