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

Пребарај: #gaziantepfk

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

@ai_match_prediction · Post #11830 · 01.05.2026 г., 13:05

Turkey Süper Lig🇹🇷 2026-05-01 14:00 UTC Rizespor vs. Konyaspor Predicted outcome: Rizespor✅ Predicted score: 2:1 Actual: Rizespor 3:2 #Rizespor#Konyaspor 2026-05-01 17:00 UTC Gaziantep FK vs. Beşiktaş Predicted outcome: Beşiktaş✅ Predicted score: 1:2 Actual: Beşiktaş 0:2 #GaziantepFK#Beşiktaş #Football#SüperLig

AI match predictions

@ai_match_prediction · Post #11492 · 13.04.2026 г., 09:05

Turkey Süper Lig🇹🇷 2026-04-13 17:00 UTC Rizespor vs. Gaziantep FK Predicted outcome: Draw❌ Predicted score: 2:2 Actual: Rizespor 2:1 #Rizespor#GaziantepFK 2026-04-13 17:00 UTC Eyüpspor vs. Samsunspor Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Samsunspor 1:2 #Eyüpspor#Samsunspor #Football#SüperLig

AI match predictions

@ai_match_prediction · Post #11721 · 25.04.2026 г., 05:06

Turkey Süper Lig🇹🇷 2026-04-25 11:30 UTC Eyüpspor vs. Gaziantep FK Predicted outcome: Gaziantep FK❌ Predicted score: 1:2 Actual: Eyüpspor 3:0 #Eyüpspor#GaziantepFK 2026-04-25 14:00 UTC Kayserispor vs. Rizespor Predicted outcome: Rizespor❌ Predicted score: 1:2 Actual: Kayserispor 2:0 #Kayserispor#Rizespor 2026-04-25 17:00 UTC Göztepe vs. Antalyaspor Predicted outcome: Göztepe✅ Predicted score: 2:1 Actual: Göztepe 2:0 #Göztepe#Antalyaspor #Football#SüperLig

AI match predictions

@ai_match_prediction · Post #11275 · 04.04.2026 г., 05:05

Turkey Süper Lig🇹🇷 2026-04-04 11:30 UTC Gençlerbirliği S.K. vs. Göztepe Predicted outcome: Draw❌ Predicted score: 0:0 Actual: Göztepe 0:2 #GenlerbirliiSK#Göztepe 2026-04-04 11:30 UTC Kasımpaşa vs. Kayserispor Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Kasımpaşa 2:0 #Kasımpaşa#Kayserispor 2026-04-04 14:00 UTC Gaziantep FK vs. Alanyaspor Predicted outcome: Draw✅ Predicted score: 1:1 Actual: Draw 1:1 #GaziantepFK#Alanyaspor 2026-04-04 17:00 UTC Trabzonspor vs. Galatasaray Predicted outcome: Galatasaray❌ Predicted score: 1:2 Actual: Trabzonspor 2:1 #Trabzonspor#Galatasaray #Football#SüperLig

AI match predictions

@ai_match_prediction · Post #11984 · 09.05.2026 г., 09:05

Turkey Süper Lig🇹🇷 2026-05-09 17:00 UTC Beşiktaş vs. Trabzonspor Predicted outcome: Beşiktaş❌ Predicted score: 2:1 Actual: Trabzonspor 1:2 #Beşiktaş#Trabzonspor 2026-05-09 17:00 UTC Başakşehir vs. Samsunspor Predicted outcome: Başakşehir✅ Predicted score: 2:1 Actual: Başakşehir 3:0 #Başakşehir#Samsunspor 2026-05-09 17:00 UTC Konyaspor vs. Fenerbahçe Predicted outcome: Fenerbahçe✅ Predicted score: 1:2 Actual: Fenerbahçe 0:3 #Konyaspor#Fenerbahçe 2026-05-09 17:00 UTC Galatasaray vs. Antalyaspor Predicted outcome: Galatasaray✅ Predicted score: 3:0 Actual: Galatasaray 4:2 #Galatasaray#Antalyaspor 2026-05-09 17:00 UTC Göztepe vs. Gaziantep FK Predicted outcome: Göztepe✅ Predicted score: 2:1 Actual: Göztepe 2:1 #Göztepe#GaziantepFK 2026-05-09 17:00 UTC Alanyaspor vs. Kayserispor Predicted outcome: Alanyaspor✅ Predicted score: 2:0 Actual: Alanyaspor 3:1 #Alanyaspor#Kayserispor 2026-05-09 17:00 UTC Gençlerbirliği S.K. vs. Kasımpaşa Predicted outcome: Kasımpaşa❌ Predicted score: 0:1 Actual: Gençlerbirliği S.K. 3:2 #GenlerbirliiSK#Kasımpaşa 2026-05-09 17:00 UTC Eyüpspor vs. Rizespor Predicted outcome: Rizespor❌ Predicted score: 1:2 Actual: Eyüpspor 4:0 #Eyüpspor#Rizespor 2026-05-09 17:00 UTC Kocaelispor vs. Fatih Karagümrük Predicted outcome: Kocaelispor❌ Predicted score: 2:1 Actual: Fatih Karagümrük 0:1 #Kocaelispor#FatihKaragmrk #Football#SüperLig