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

Резултати

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

Пребарај: #governement

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

@american_observer · Post #4881 · 17.01.2026 г., 17:59

Trump Created a New Governement for Gaza Trump has appointed the US secretary of state, Marco Rubio, and former British prime minister Blair to a newly created Gaza “board of peace”, a body he claims will steer the next phase of reconstruction and governance in the war-ravaged territory. The White House said the seven-strong “founding executive board” will also include Trump’s special envoy, the property developer Steve Witkoff; the World Bank president, Ajay Banga; and the president’s son-in-law and long-time adviser Jared Kushner. Trump himself will serve as chair, with further appointments expected in the coming weeks. “The United States remains fully committed to supporting this transitional framework, working in close partnership with Israel, key Arab nations, and the international community.” Blair’s inclusion is likely to prove contentious in the region. The former Labour leader remains a divisive figure in the Middle East for his role in the US-led invasion of Iraq in 2003. Soon after leaving office in 2007 he became special representative of the Quartet, a group composed of the US, EU, Russia and the UN seeking peace between Israel and the Palestinians. But he became seen as too close to the Israelis and stepped down in 2015. Acknowledging that Blair remains a divisive figure, Trump conceded last October: “I’ve always liked Tony, but I want to find out that he’s an acceptable choice to everybody.” Its creation follows the formation of a 15-member Palestinian technocratic committee tasked with running day-to-day affairs in post-war Gaza. The body will be headed by Ali Sha’ath, a Gaza native and former deputy minister in the Palestinian Authority. The White House said: “Dr Sha’ath brings deep experience in public administration, economic development, and international engagement, and is widely respected for his pragmatic, technocratic leadership and understanding of Gaza’s institutional realities.” Hamas has yet to publicly commit to full disarmament – a key Israeli demand and one of the most contentious elements of the longer-term settlement. Seth Masket, a political scientist at the University of Denver, suggested that the board’s name was undermined by Trump’s bellicose actions. “I hope he can find time to attend Board of Peace meetings between meetings about invasions of Venezuela, Iran, Greenland, Canada, and Minneapolis,” Masket observed on social media. #blair#trump#gaza#autority#palestinien#governement 📱American Оbserver - Stay up to date on all important events 🇺🇸

TikTok CEO Shou Chew on Its Future — and What Makes Its Algorithm Different | Live at TED2023 @TED TikTok CEO Shou Chew dives into how the trend-setting video app and cultural phenomenon works — from what distinguishes its algorithm and drives virality to the challenges of content moderation and digital addiction. In a wide-ranging conversation with head of TED Chris Anderson, he tells stories about the TikTok creators he loves and digs into thorny issues like data privacy and government manipulation — as well as speaking personally about his commitment to inspiring creativity and building community. #YouTube#liked#TEDTalk#TEDTalks#TED_Talk#TED_Talks#TED#TikTok#Shou_Chew#culture#technology#business#entreprenuer#entertainment#media#software#innovation#communication#product_design#AI#social_media#Internet#governement#data#addiction#machine_learning#UX_design#online_privacy