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

Резултати

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

Пребарај: #losangeles

当前筛选 #losangeles清除筛选
ℭ𝔬𝔪𝔟𝔞𝔱𝔩𝔳𝔩™

@realcombatlvl · Post #24622 · 04.08.2025 г., 02:15

🇺🇸#LosAngeles. Wild teens ransack Chevron store in Lincoln Heights in broad daylight. Another SoCal store is taken over by rampaging teens racksacking aisles, grabbing whatever they can. This time, a Lincoln Heights Chevron station is hit. The frustrated store managers who want police to do more to stop the takeovers. Follow us -> LiveLeak

Hashtags

Dr Sherri Tenpenny

@SherriTenpenny · Post #24757 · 19.04.2026 г., 05:24

This is absolutely disgusting and heartbreaking. Homeless addicts on Skid Row in LA are using innocent dogs to test their drugs for fentanyl. These poor animals are being fed deadly substances, abused, neglected, sold for drugs, and thrown away like trash. Volunteers from Starts With One Today are risking their lives to rescue these dogs with zero support from the city. How has Mayor Karen Bass and LA leadership let this horror continue? Animals are suffering and dying in plain sight while officials do nothing. This is pure cruelty. Where is the outrage? Where is the action? #SaveSkidRowDogs#AnimalAbuse#LosAngeles 🔹👉🏻@SherriTenpenny

Jeffery Mead

@the_jefferymead · Post #507 · 19.02.2026 г., 05:55

PERFECT RING FORMED OVER LOS ANGELES This appeared high above L.A. just after dusk. A bright linear trail stretched across the sky — and around it, a smooth circular arc expanded and held its shape. The symmetry is what stands out. A straight line through the center. A clean curve wrapping around it. It lingered long enough for people across the city to stop and stare. Los Angeles, California. Did you catch this from where you are? MrMBB333 👇 Drop your city. #MrMBB333#SkyWatch#LosAngeles

AI match predictions

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

USA Major League Soccer🇺🇸 2026-05-10 20:30 UTC New York City FC vs. Columbus Crew Predicted outcome: New York City FC✅ Predicted score: 3:2 Actual: New York City FC 3:0 #NewYorkCity#ColumbusCrew 2026-05-10 23:00 UTC Minnesota United FC vs. Austin Predicted outcome: Minnesota United FC❌ Predicted score: 2:1 Actual: Draw 2:2 #MinnesotaUnited#Austin 2026-05-11 01:00 UTC Los Angeles FC vs. Houston Dynamo Predicted outcome: Los Angeles FC❌ Predicted score: 2:1 Actual: Houston Dynamo 1:4 #LosAngeles#HoustonDynamo #Football#USAMLS

12
ПретходнаСтраница 1 од 2Следна