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

Пребарај: #larisa

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

@ai_match_prediction · Post #12061 · 12.05.2026 г., 09:05

Greece Super League 1🇬🇷 2026-05-12 16:00 UTC Panetolikos vs. Larisa Predicted outcome: Panetolikos❌ Predicted score: 2:1 Actual: Draw 1:1 #Panetolikos#Larisa 2026-05-12 16:00 UTC Asteras Tripolis vs. Panserraikos Predicted outcome: Asteras Tripolis✅ Predicted score: 2:1 Actual: Asteras Tripolis 1:0 #Asteras#Panserraikos 2026-05-12 16:00 UTC Kifisia vs. Atromitos Predicted outcome: Atromitos✅ Predicted score: 1:2 Actual: Atromitos 0:3 #Kifisia#Atromitos #Football#GreeceSuperLeague1

AI match predictions

@ai_match_prediction · Post #11977 · 09.05.2026 г., 05:05

Greece Super League 1🇬🇷 2026-05-09 13:00 UTC Panserraikos vs. Kifisia Predicted outcome: Kifisia✅ Predicted score: 1:2 Actual: Kifisia 1:2 #Panserraikos#Kifisia 2026-05-09 14:00 UTC Larisa vs. Asteras Tripolis Predicted outcome: Larisa❌ Predicted score: 2:1 Actual: Draw 1:1 #Larisa#Asteras 2026-05-09 16:30 UTC Atromitos vs. Panetolikos Predicted outcome: Atromitos❌ Predicted score: 2:1 Actual: Panetolikos 1:2 #Atromitos#Panetolikos #Football#GreeceSuperLeague1

AI match predictions

@ai_match_prediction · Post #11857 · 02.05.2026 г., 09:06

Greece Super League 1🇬🇷 2026-05-02 14:00 UTC Panetolikos vs. Kifisia Predicted outcome: Panetolikos❌ Predicted score: 2:1 Actual: Kifisia 0:1 #Panetolikos#Kifisia 2026-05-02 14:30 UTC Panserraikos vs. Larisa Predicted outcome: Larisa❌ Predicted score: 1:2 Actual: Draw 1:1 #Panserraikos#Larisa 2026-05-02 16:30 UTC Asteras Tripolis vs. Atromitos Predicted outcome: Atromitos❌ Predicted score: 1:2 Actual: Asteras Tripolis 4:2 #Asteras#Atromitos #Football#GreeceSuperLeague1

AI match predictions

@ai_match_prediction · Post #11756 · 26.04.2026 г., 09:06

Greece Super League 1🇬🇷 2026-04-26 13:00 UTC Kifisia vs. Panetolikos Predicted outcome: Kifisia❌ Predicted score: 2:1 Actual: Draw 0:0 #Kifisia#Panetolikos 2026-04-26 15:00 UTC Atromitos vs. Asteras Tripolis Predicted outcome: Atromitos✅ Predicted score: 1:0 Actual: Atromitos 2:1 #Atromitos#Asteras 2026-04-26 17:00 UTC Larisa vs. Panserraikos Predicted outcome: Larisa❌ Predicted score: 2:1 Actual: Panserraikos 0:1 #Larisa#Panserraikos #Football#GreeceSuperLeague1

AI match predictions

@ai_match_prediction · Post #11652 · 22.04.2026 г., 05:05

Greece Super League 1🇬🇷 2026-04-22 13:00 UTC Panserraikos vs. Atromitos Predicted outcome: Atromitos✅ Predicted score: 0:1 Actual: Atromitos 0:4 #Panserraikos#Atromitos 2026-04-22 14:00 UTC Larisa vs. Kifisia Predicted outcome: Draw✅ Predicted score: 1:1 Actual: Draw 1:1 #Larisa#Kifisia 2026-04-22 17:00 UTC Asteras Tripolis vs. Panetolikos Predicted outcome: Asteras Tripolis✅ Predicted score: 1:0 Actual: Asteras Tripolis 2:1 #Asteras#Panetolikos #Football#GreeceSuperLeague1

AI match predictions

@ai_match_prediction · Post #11370 · 08.04.2026 г., 05:05

Greece Super League 1🇬🇷 2026-04-08 13:00 UTC Larisa vs. Panetolikos Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Panetolikos 1:2 #Larisa#Panetolikos 2026-04-08 14:00 UTC Panserraikos vs. Asteras Tripolis Predicted outcome: Draw✅ Predicted score: 1:1 Actual: Draw 0:0 #Panserraikos#Asteras 2026-04-08 16:00 UTC Atromitos vs. Kifisia Predicted outcome: Atromitos❌ Predicted score: 1:0 Actual: Draw 0:0 #Atromitos#Kifisia #Football#GreeceSuperLeague1

AI match predictions

@ai_match_prediction · Post #11276 · 04.04.2026 г., 05:06

Greece Super League 1🇬🇷 2026-04-04 13:00 UTC Kifisia vs. Panserraikos Predicted outcome: Kifisia❌ Predicted score: 2:1 Actual: Panserraikos 1:2 #Kifisia#Panserraikos 2026-04-04 15:00 UTC Asteras Tripolis vs. Larisa Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Asteras Tripolis 3:1 #Asteras#Larisa 2026-04-04 17:00 UTC Panetolikos vs. Atromitos Predicted outcome: Draw✅ Predicted score: 1:1 Actual: Draw 1:1 #Panetolikos#Atromitos #Football#GreeceSuperLeague1

AI match predictions

@ai_match_prediction · Post #11562 · 18.04.2026 г., 05:05

Greece Super League 1🇬🇷 2026-04-18 13:00 UTC Kifisia vs. Asteras Tripolis Predicted outcome: Kifisia❌ Predicted score: 1:0 Actual: Draw 0:0 #Kifisia#Asteras 2026-04-18 14:00 UTC Atromitos vs. Larisa Predicted outcome: Atromitos✅ Predicted score: 1:0 Actual: Atromitos 3:2 #Atromitos#Larisa 2026-04-18 15:00 UTC OFI vs. Levadiakos Predicted outcome: Draw❌ Predicted score: 2:2 Actual: OFI 2:0 #OFI#Levadiakos 2026-04-18 16:00 UTC Aris Thessalonikis vs. Volos NFC Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Aris Thessalonikis 3:2 #Aris#Volos 2026-04-18 17:00 UTC Panetolikos vs. Panserraikos Predicted outcome: Panetolikos❌ Predicted score: 1:0 Actual: Panserraikos 2:3 #Panetolikos#Panserraikos #Football#GreeceSuperLeague1

AI match predictions

@ai_match_prediction · Post #11156 · 22.03.2026 г., 09:06

Greece Super League 1🇬🇷 2026-03-22 17:00 UTC Olympiakos Piraeus vs. Larisa Predicted outcome: Olympiakos Piraeus❌ Predicted score: 2:0 Actual: Draw 0:0 #Olympiakos#Larisa 2026-03-22 17:00 UTC AEK Athens FC vs. Kifisia Predicted outcome: AEK Athens FC✅ Predicted score: 3:1 Actual: AEK Athens FC 3:0 #AEK#Kifisia 2026-03-22 17:00 UTC Panetolikos vs. Panserraikos Predicted outcome: Panetolikos❌ Predicted score: 2:1 Actual: Draw 0:0 #Panetolikos#Panserraikos 2026-03-22 17:00 UTC Asteras Tripolis vs. Panathinaikos Predicted outcome: Panathinaikos✅ Predicted score: 1:2 Actual: Panathinaikos 1:2 #Asteras#Panathinaikos 2026-03-22 17:00 UTC Levadiakos vs. Atromitos Predicted outcome: Levadiakos✅ Predicted score: 2:1 Actual: Levadiakos 1:0 #Levadiakos#Atromitos 2026-03-22 17:00 UTC Aris Thessalonikis vs. OFI Predicted outcome: Aris Thessalonikis❌ Predicted score: 1:0 Actual: OFI 0:2 #Aris#OFI 2026-03-22 17:00 UTC Volos NFC vs. PAOK Predicted outcome: PAOK❌ Predicted score: 0:2 Actual: Volos NFC 2:1 #Volos#PAOK #Football#GreeceSuperLeague1