Gregory P. Smith wrote: > > The documentation for the struct module says: > > http://docs.python.org/dev/library/struct.html#module-struct > > " short is 2 bytes; int and long are 4 bytes; long long ( __int64 on > Windows) is 8 bytes" > > and lists 'l' and 'L' as the pack code for a C long. > > As its implemented today, the documentation is incorrect. On an LP64 > host (pretty much any 64-bit linux, bsd or unixish thing) a long is 8 > bytes.
You overlooked the words "Standard size and alignment are as follows" that start the quoted paragraph. It's a little confusing because standard size is not the default. The default is platform-specific sizes. Only if you start the format string with >, <, ! or = do you get standard sizes. The reference documentation is correct as it stands, and, I suspect, so is the LP64 implementation. Doesn't struct.pack('>l',42) produce a 4-byte string on LP64? The tutorial at http://docs.python.org/tut/node13.html#SECTION0013300000000000000000%3E has a bug though: the format string should use '<'. I believe zipfile.py correctly uses '<' throughout. regards, Anders _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com