On Dec 29, 2013, at 14:38, Chris Angelico firstname.lastname@example.org wrote:
On Mon, Dec 30, 2013 at 9:31 AM, Andrew Barnert email@example.com wrote:
And if you're running a 32-bit python on 64-bit Windows you almost certainly want to download 64-bit libraries, right?
Actually, that one's a bit harder to work out. I'd say uname() would say that it's a 64-bit system (of whatever architecture), so all you have is the platform module and its methods of looking at sys.executable - and the docs comments kinda scare me off using that anywhere other than Linux (and even there, it looks inefficient). Is there a best-practice way of finding out what binary libraries you should be using for this process? Surely that should be a simple thing?
Sure. And this is all documented in the first place I would have thought to look--right near the top of the platform module, the first thing that comes up when I google "python platform" or "python architecture".
There are actually 4 different things you could be asking for, not just 2 (even ignoring the fact that you can have different architectures that aren't just 32- and 64-bit versions of the same thing).
What you really want here is probably not whether you're on a 64-bit OS, or whether Python was built 64-bit--if you ever care about any platform besides Windows, you may be running under a fat/universal binary that could be built for both 32- and 64-bit, and you want to know which one it's being _run_ as. So, as the docs say:
To get at the "64-bitness" of the current interpreter, it is more reliable to query the sys.maxsize attribute.
Maybe that could be given a nicer name, but adding an "os.architecture" that gives you a different of the four values than "platform.architecture" and probably isn't the one you want as Anatoly suggested doesn't seem like an improvement.
Maybe we could have different functions in platform for hardware_architecture, os_architecture, executable_architecture, and interpreter_architecture? But I don't think they would get much use. Besides, historically I've been as interested in knowing whether I was on, say, real ARM7 or ARM9 emulating ARM7 as in real i386 or x86_64 emulating i386, where there's no simple 32 vs. 64 cross-platform answer that has any meaning, and I don't see any reason to believe that the future will be different, just because the present happens to be different on one platform.