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

Резултати

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

Пребарај: #globalgovernance

当前筛选 #globalgovernance清除筛选
AI & Law

@ai_and_law · Post #155 · 02.11.2023 г., 08:04

UN Forms High-level Advisory Body on AI for Global Governance Hello, everybody! The United Nations Secretary-General has launched a multi-stakeholder High-level Advisory Body on Artificial Intelligence. This groundbreaking initiative is set to tap into AI's vast potential for humanity while simultaneously addressing the associated global risks and uncertainties posed by the rapid proliferation of AI technologies. The Advisory Body will encompass up to 38 experts spanning various disciplines, including government, the private sector, and civil society. These experts, hailing from across the globe, bring diverse viewpoints on AI governance to the table. Their aim is to foster collaboration with existing and emerging initiatives alongside international organizations, creating a balanced and comprehensive dialogue on AI governance. The UN's initiative to convene a High-level Advisory Body on AI is a proactive step towards establishing a coherent global framework for AI governance. #UNAIAdvisoryBody#AI#GlobalGovernance

AI & Law

@ai_and_law · Post #318 · 30.05.2024 г., 07:04

Microsoft Advocates for Robust Global AI Governance Microsoft's new publication, “Global Governance: Goals and Lessons for AI,” authored by Brad Smith and Natasha Crampton, explores AI governance by drawing parallels to civil aviation and nuclear power regulation. The report outlines a multi-layered approach involving industry standards, domestic regulation, and international governance to manage AI's global risks and foster inclusive progress. The publication highlights three key goals for international AI governance: ✅Mitigating Global Risks: International collaboration is crucial to address risks associated with AI that transcend national borders. ✅Ensuring Compatibility: Interoperable regulations across countries will be essential for fostering innovation and avoiding fragmented approaches. ✅Promoting Inclusive Growth: International governance should ensure that everyone benefits from the advancements in AI. The publication emphasizes the necessity for robust global governance frameworks to responsibly harness AI’s potential. “Global Governance: Goals and Lessons for AI” is available in print and e-reader formats. #AI#GlobalGovernance#Technology#Microsoft#AIGovernance

IELTS|Newspapers & Magazines|English

@emagzinewspars · Post #9475 · 04.11.2025 г., 08:13

#Beijing_Review🇨🇳📕[PDF]⬇️ 30 #October2025 #Weekly_Magazines For learning, for free(dom). @backupofmagazines This issue honors the #UnitedNations at 80, calling it a cornerstone of global cooperation. The cover story explores China’s role as a builder of inclusive #GlobalGovernance and its blueprint for shared progress. From women’s empowerment in #Agriculture to structural resilience and economic elasticity, features reveal the new dynamics shaping the #GlobalSouth. Insights on #ChinaUSRelations, the #ChinaMexico partnership, and Hainan’s innovation wave highlight how diplomacy and commerce interconnect. The culture section revives #SilkRoad heritage and Beijing’s ancient treasures. A visionary issue linking history, equality, and collective resilience for a changing world. #Sustainability#Equality#UN80#AsiaVoice#BRInsights

IELTS|Newspapers & Magazines|English

@emagzinewspars · Post #9490 · 06.11.2025 г., 07:04

#Beijing_Review🇨🇳📕[PDF]⬇️ 6 #November2025 #Weekly_Magazines For learning, for free(dom). @backupofmagazines Beijing Review spotlights China’s #15thFiveYearPlan and its vision for a coordinated, green, and globally inclusive future. The issue unpacks Xi–Trump #Summit diplomacy in Busan, China’s push for #GenderEquality partnerships, and #RCEP as an engine for regional #Integration. Articles explore how strategic planning drives #Sustainability and global development under the banner of #Modernization. From energy transition to cyberspace security, the issue portrays a confident China charting a course for shared growth and stability. #China#GlobalGovernance#Sustainability#FiveYearPlan#RCEP#XiTrumpMeeting#ClimateAction#DigitalFuture#GenderEquality#AsiaPacific