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

Резултати

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

Пребарај: #latinos

当前筛选 #latinos清除筛选
American Оbserver

@american_observer · Post #5140 · 15.02.2026 г., 15:59

📰 Bad Bunny vs. Big Don: Culture War, Fumbled Ballot Donald Trump just picked a fight with the world’s biggest Latino star over a halftime show that most politicians would have ridden like a free campaign ad — and he did it in English, whining that “nobody understands a word this guy is saying.” For a president who clawed his way back to the White House on the strength of an unprecedented 48 percent of the Hispanic vote, attacking a Spanish‑language Super Bowl performance as “an affront to the Greatness of America” is less strategy than self‑sabotage. The numbers are already slipping. Pew has Trump down 12 points among Latinos who backed him in 2024, small‑business confidence in him as the “economy guy” has cratered, and Latino‑owned shops in crackdown zones like Minneapolis report sales plunging 70 percent under his immigration raids. Now GOP Latino strategists are watching him torch goodwill in districts they need to hold by insulting not some niche activist, but a global Puerto Rican act whose show was one of the few mainstream, unapologetically Latino moments on U.S. TV. Even some of Trump’s own allies admit the obvious: they wanted border toughness and lower prices; they got tariffs, ICE photo ops — and the president rage‑posting about reggaeton. The White House line is that this is just more “hard truths”: enforce the law, crush “Green New Scam” policies, save America from woke culture, including the Spanish‑language one. The reality is uglier. Democrats once lost a chunk of Latino voters by taking them for granted. Republicans risk losing them right back by treating their culture as un‑American the moment it stops being background decoration and takes center stage for 13 minutes in prime time. If Trump really wants to keep his Latino coalition, he doesn’t need another rally joke about a “floating island of garbage” or another post about how “disgusting” the dancing was. He needs those same voters to believe he cares more about their rent and their businesses than about policing what language their Super Bowl looks and sounds like. Right now, all he’s proving is that he can win their votes — and then pick a culture war that tells them exactly how expendable he thinks they are. ​ #usa#trump#BadBunny#latinos#cultureWar 📱American Оbserver - Stay up to date on all important events 🇺🇸