TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #241 · 5 мај

Можно ли в Python создавать бинарные файлы? Конечно можно. Для этого в Python есть следующие инструменты: ▫️ тип данных bytes и bytearray ▫️ открытие файла в режиме wb (write binary) или rb (read binary) ▫️ модуль struct Про модуль struct поговорим в первую очередь. Файл в формате JSON или Yaml внутри себя содержит разметку данных. Всегда можно определить где список начался а где закончился. Где записана строка а где словарь. То есть формат записи данных содержит в себе элементы разметки данных. В binary-файле данные не имеют визуальной разметки. Это просто байты, записанные один за другим. Правила записи и чтения находятся вне файла. Модуль struct как раз и помогает с организацией данных в таком файле с помощью определения форматов записи для разных частей файла. Модуль struct преобразует Python-объекты в массив байт, готовый к записи в файл и имеющий определённый вид. Для этого всегда следует указывать формат преобразования (или, как оно здесь называется - запаковки). Формат нужен для того, чтобы выделить достаточное количество байт для записи конкретного типа объекта. В последствии с помощью того же формата будет производиться чтение. При этом следует помнить что мы говорим о типах языка С а не Python. Именно формат определяет, что записано в конкретном месте файла, число, строка или что-то еще. Вот какие токены формата у нас есть. Помимо этого, первым символом можно указать порядок байтов. На разных системах одни и те же типы данных могут записываться по-разному, поэтому желательно указать конкретный способ из доступных. Если этого не сделать, то используется символ '@', то есть нативный для текущей системы. В строке формата мы пишем в каком порядке и какие типы собираемся преобразовать в байты. Запакуем в байты простое число, токен "i". >>> import struct >>> struct.pack('=i', 10) b'\n\x00\x00\x00' Теперь несколько float, при этом нужно передавать элементы не массивом а последовательностью аргументов. >>> struct.pack('=fff', 1.0, 2.5, 4.1) b'\x00\x00\x80?\x00\x00 @33\x83@' Вместо нескольких токенов можно просто указать нужное количество элементов перед одним токеном, результат будет тот же. >>> struct.pack('=3f', 1.0, 2.5, 4.1) b'\x00\x00\x80?\x00\x00 @33\x83@' Теперь запакуем разные типы >>> data = struct.pack('=fiQ', 1.0, 4, 100500) я запаковал типы float, int и unsigned long long (очень большой int, на 8 байт) b'\x00\x00\x80?\x04\x00\x00...' Распаковка происходит аналогично, но нужно указать тот же формат, который использовался при запаковке. Результат возвращается всегда в виде кортежа. >>> struct.unpack('=fiQ', data) (1.0, 4, 100500) Как видите, ничего страшного! #lib#basic

Hashtags

Резултати

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

Пребарај: #gpai

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

@ai_and_law · Post #622 · 28.07.2025 г., 07:04

🇪🇺EU Mandates Transparency on AI Training Data for GPAI The EU has released its official template for the mandatory training data summary required under Article 53(1)(d) of the EU AI Act. Starting August 2, providers of general-purpose AI models must publicly disclose a sufficiently detailed overview of the content used for model training. This includes naming major datasets, public or private, and offering narrative context for other sources, as clarified in Recital 107. This is a structural shift in regulatory expectations. AI developers can no longer obscure data provenance or sidestep questions of copyright and data protection. The summary isn’t just a compliance formality, it’s a mechanism for enforcement. Rights holders and regulators finally gain a clear window into the inputs behind powerful AI systems. #GPAI#EUAIAct

AI & Law

@ai_and_law · Post #457 · 04.12.2024 г., 08:04

Decoding the AI Act: Q&A on General-Purpose AI The AI Office has released a detailed Q&A to clarify critical aspects of the AI Act, focusing on general-purpose AI (GPAI). While emphasizing that only EU Courts can provide definitive interpretations, the document addresses GPAI risks, provider obligations, and compliance requirements. It also sheds light on the role of the General-Purpose AI Code of Practice, including its legal implications, limitations, and specific provisions for startups. Key insights include requirements for open-source models, R&D exemptions, and obligations tied to model fine-tuning. The document outlines enforcement mechanisms and a timeline for finalizing the Code of Practice, stressing its importance as a guide rather than a binding regulation. This Q&A provides essential context for stakeholders navigating the evolving AI regulatory landscape. #AIRegulation#GPAI#AIEthics#AIAct

AI & Law

@ai_and_law · Post #605 · 02.07.2025 г., 07:04

🇪🇺AI Rules Must Serve People, Not Just Platforms: Open Letter to the European Commission A powerful coalition including Nobel laureates Daron Acemoglu and Geoffrey Hinton has called on the European Commission to stay the course on general-purpose AI (GPAI) regulation. In a joint letter to President von der Leyen, researchers, civil society leaders, and industry experts urge EU leaders not to weaken GPAI rules under pressure from tech lobbies. Their message: innovation and rights protection are not mutually exclusive. The signatories back the Code of Practice developed over the past nine months as a pragmatic governance tool — one that applies only to 5–15 major players and mirrors existing risk management norms. They recommend mandatory third-party testing for systemic-risk models, agile review mechanisms, and significant resourcing of the AI Office, including 300 dedicated personnel and top-tier safety expertise. #AIRegulation#GPAI#AIEthics#EUAIAct

AI & Law

@ai_and_law · Post #813 · 24.04.2026 г., 07:04

🇪🇺First Scholarly Commentary Focuses on EU GPAI Rules The Leverhulme Centre for the Future of Intelligence at the University of Cambridge and the Institute for Law & AI have launched the first academic commentary dedicated exclusively to the general-purpose AI (GPAI) model provisions of the EU AI Act. The project addresses regulatory uncertainty surrounding GPAI systems, particularly models that may present systemic risk. Rather than promoting a single interpretation, the commentary analyzes each provision by outlining where the law is clear, where ambiguity remains, and the strongest legal arguments on competing sides. The initiative launches with Chapter V of the AI Act, with additional articles to be released on a rolling basis. #AIRegulation#EUAIAct#GPAI#LegalResearch#AIGovernance

इस हफ्ते का #FridaysAtMyGov लाइव हो चुका है।। 🥳 आइए इस लेटेस्ट एपिसोड में #GPAI शिखर सम्मेलन में नए भारत की एआई के क्षेत्र में बढ़ती ताकत को जानें। अभी देखें पूरा एपिसोड: https://youtu.be/ABfmjdKoz2c?feature=shared #NewIndia#MyGov #GPAISummit

AI & Law

@ai_and_law · Post #617 · 18.07.2025 г., 07:04

🇪🇺 EU AI Act: Voluntary Code, Strategic Signal The EU AI Office is now officially inviting general-purpose AI model providers to sign the General-Purpose AI Code of Practice. Signing is voluntary — but strategic. Companies like OpenAI and Mistral have already committed, signaling alignment with the EU’s emerging regulatory expectations. Signatories gain more than reputational capital: the EU Commission will prioritize monitoring adherence to the code rather than imposing full administrative scrutiny. This approach offers regulatory predictability and reduced compliance burden — a clear incentive ahead of the AI Act’s enforcement starting 2 August 2025. The list of signatories will be published on 1 August 2025. #AIRegulation#EUAIAct#GPAI#AIEthics # #OpenAI#Mistral