Deutsch English Français Italiano |
<v4tquf$1qn6n$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: David Brown <david.brown@hesbynett.no> Newsgroups: comp.lang.c Subject: Re: Baby X is bor nagain Date: Wed, 19 Jun 2024 07:39:26 +0200 Organization: A noiseless patient Spider Lines: 32 Message-ID: <v4tquf$1qn6n$1@dont-email.me> References: <v494f9$von8$1@dont-email.me> <v49seg$14cva$1@raubtier-asyl.eternal-september.org> <v49t6f$14i1o$1@dont-email.me> <v4bcbj$1gqlo$1@raubtier-asyl.eternal-september.org> <v4bh56$1hibd$1@dont-email.me> <v4c0mg$1kjmk$1@dont-email.me> <v4c8s4$1lki1$4@dont-email.me> <20240613002933.000075c5@yahoo.com> <v4emki$28d1b$1@dont-email.me> <20240613174354.00005498@yahoo.com> <v4okn9$flpo$2@dont-email.me> <20240617002924.597@kylheku.com> <v4pddb$m5th$1@dont-email.me> <20240618115650.00006e3f@yahoo.com> <v4rv0o$1b7h1$1@dont-email.me> <20240618184026.000046e1@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 19 Jun 2024 07:39:27 +0200 (CEST) Injection-Info: dont-email.me; posting-host="0e1bf1c39b81cc98682be3a9709bb4b3"; logging-data="1924311"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19PHtxD5j0XCpAJW2lzarSNKUtOPX3Jnr8=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:yprBNU5h8rJ+wHy4/higYkdi6HU= In-Reply-To: <20240618184026.000046e1@yahoo.com> Content-Language: en-GB Bytes: 2956 On 18/06/2024 17:40, Michael S wrote: > On Tue, 18 Jun 2024 14:36:40 +0200 > David Brown <david.brown@hesbynett.no> wrote: > >> >> Of course if you don't know Python, it will be slower to write it in >> Python! >> > > I don't know Python well, but it does not meant that I don't know it at > all. > Few minutes ago I took a look into docs and it seems that situation with > writing binary data files with predefined layout is better than what I > was suspecting. They have something called "Buffer Protocol". It allows > to specify layout in declarative manner, similarly to C struct or may > be even to Ada's records with representation clause. > However attempt to read the doc page further down proved that my > suspicion about steepness of the learning curve was not wrong :( > > "Buffer protocol" is for passing data between Python and C extensions, which is certainly a complicated business. For dealing with binary data in specific formats in Python, the "struct" module is your friend. It lets you pack and unpack data with specific sizes and endianness using a compact format string notation. I've used it for dealing with binary file formats and especially for network packets. There's also the ctypes module which is aimed at duplicating C-style types and structures, primarily for interfacing with DLL's and dynamic so libraries.