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

Пребарај: #privacyrights

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

@ai_and_law · Post #532 · 24.03.2025 г., 08:04

🇳🇴OpenAI Faces GDPR Complaint Over ChatGPT’s False Accusation of Murder Privacy group Noyb has filed a complaint with the Norwegian Data Protection Authority, alleging OpenAI violated GDPR after ChatGPT falsely claimed a Norwegian man was convicted of murdering his children. The chatbot’s response contained both fabricated details and accurate personal information, raising concerns about AI-generated defamation. Noyb argues that OpenAI is still processing inaccurate personal data within its model, even if the output has been corrected. The complaint cites GDPR’s requirement for accurate data processing and demands OpenAI delete defamatory information, fine-tune its model, and face financial penalties to prevent future violations. This case underscores a growing regulatory challenge: how to enforce data accuracy in AI systems that continuously evolve. #GDPR#AIRegulation#PrivacyRights#ChatGPT

AI & Law

@ai_and_law · Post #230 · 01.02.2024 г., 08:04

US Lawmakers Propose DEFIANCE Act Against Nonconsensual AI-Generated Porn Hello, everyone! US senators, including Dick Durbin and Lindsey Graham, introduced the Disrupt Explicit Forged Images and Non-Consensual Edits (DEFIANCE) Act. The bill aims to combat the rising tide of AI-generated explicit images, providing a civil right of action for victims depicted without consent. It follows the controversy over digitally manipulated explicit images of Taylor Swift. The DEFIANCE Act broadens the scope beyond AI-generated content to encompass any "intimate" sexual image created through various means, targeting those who knowingly produce or possess such content for dissemination. The proposed legislation aligns with President Biden's push for AI regulation. #DEFIANCEAct#PrivacyRights#AIRegulation

AI & Law

@ai_and_law · Post #200 · 26.12.2023 г., 08:04

FTC bans Rite Aid from using AI facial recognition in stores for 5 years Hello everybody! The US Federal Trade Commission (FTC) has barred American drugstore giant Rite Aid from utilizing AI facial recognition technology for surveillance purposes over the next five years. The FTC intervened as Rite Aid allegedly "failed to implement reasonable procedures" in deploying facial recognition across 200 stores over eight years. Rite Aid's facial recognition system, designed to identify past shoplifters, resulted in numerous false positives. Tens of thousands of individuals were included, often with low-quality images from various sources, leading to unwarranted confrontations and police interventions, disproportionately impacting people of color. Rite Aid is mandated to delete collected images, algorithms, and related products, notify consumers, enhance data security measures, and provide clear notices regarding any biometric surveillance technology in stores. Rite Aid, while agreeing to the FTC settlement, expressed fundamental disagreement with the facial recognition allegations. The company halted the technology's use three years prior to the FTC investigation and commits to fortifying information security practices. #AILaw#PrivacyRights#FacialRecognition#FTC#RiteAid#LegalTech

AI & Law

@ai_and_law · Post #628 · 05.08.2025 г., 07:04

🇬🇧UK Parliament Launches Human Rights Inquiry in the AI Era The U.K. Parliament’s Joint Committee on Human Rights has opened a formal inquiry into how artificial intelligence is impacting fundamental rights. Key focus areas include privacy, discrimination, algorithmic bias, and mechanisms for redress when AI systems cause harm. The committee is also evaluating whether current legal frameworks are sufficient, or if new legislation is needed to safeguard human rights in the face of accelerating AI adoption. Public submissions are open until 5 September. #AIandLaw#HumanRights#AIRegulation#UKParliament#AlgorithmicBias#PrivacyRights#Accountability#AIGovernance