在 64 位操作系统的 64 位 CPU 上运行 X86-64 Python 有好处吗?

发布于 2024-10-09 19:19:10 字数 342 浏览 2 评论 0原文

运行 Python 和扩展的 amd64 版本有哪些好处? (这里有很多扩展为 amd64 编译。)我有一个 i5 处理器和 Win7 64 位,所以看起来比较合适。但它听起来也像是有缺陷、测试版、不受支持等。

它真的提供了性能优势吗?在哪些领域?我会运行 SciPy、NumPy 等。使用 32 位 Python 时,我偶尔会遇到“内存不足”错误,并且我的机器有 4 GiB RAM。

如果不存在 64 位版本的软件包,是否可以在 64 位 Python 基础上安装 win32 软件包?

What kind of benefits are there to running the amd64 builds of Python and extensions? (Lots of extensions compiled for amd64 here.) I have an i5 processor and Win7 64-bit, so it seems like it would be appropriate. But it also sounds like it is buggy, beta, unsupported, etc.

Does it actually provide a performance benefit? In which areas? I'd be running SciPy, NumPy, etc. I occasionally get "out of memory" errors with 32-bit Python and my machine has 4 GiB of RAM.

Can win32 packages be installed on a 64-bit Python base if no 64-bit version of the package exists?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

药祭#氼 2024-10-16 19:19:10

使用 64 位 Python 的主要理由是您可以访问超过 2GB 的主内存,例如,如果您有大型字典、列表或长字符串。这要求您的系统实际上有足够的内存才能实用。

第二个影响是,在 AMD64 模式下,CPU 具有更多寄存器,因此生成的代码可能运行得稍快一些(对于整数运算)。

Windows 上 64 位模式的 Python 当然不是测试版或不受支持。它可能有错误,但前提是您确实拥有非常大的数据结构。 64 位 Python 已经有大约 15 年的历史了(尽管不是在 Windows 上)。

The primary rationale to use a 64-bit Python is that you can access more than 2GB of main memory, e.g. if you have large dicts, lists, or long strings. This requires that you actually have that much memory in your system to be practical.

A secondary effect is that in AMD64 mode, the CPU has more registers, so the resulting code may run slightly faster (for integer operations).

Python in 64-bit mode on Windows certainly is not beta or unsupported. It may be buggy, but only if you actually do have very large data structures. 64-bit Python has been around 15 years (though not on Windows).

风苍溪 2024-10-16 19:19:10

与其他 64 位程序具有相同的优势:大量的进程空间,以及可以访问更多更大的寄存器(至少对于 VM 和 C 模块而言)。但不行,您需要找到 64 位版本的 C 模块。

Same advantage as every other 64-bit program: lots of process space, and access to more and larger registers (for the VM and C modules at least). But no, you need to find 64-bit versions of the C modules.

杯别 2024-10-16 19:19:10

一般来说,使用 64 位代码可以获得的正常收益。我还没有找到任何最近的基准测试,但在引入 x64 时,在 x86 硬件上,代码在 64 位上的运行速度比在 32 位上快 30%——随着自那时以来的优化,这种差距肯定已经在某种程度上缩小了,但仍然可能更快。

此外,如果您也需要的话,您还可以透明地使用超过 4GB 的内存。

但请注意,64 位的速度提升是由于可怕的 32 位传统 ABI:在 32 位中运行的核心 i7 具有与 1987 年 80386 芯片中相同的 4 个通用寄存器(以及其他几个)。从 70 年代开始,8086 上的寄存器是 1:1 的。 64 位 abi 引入了更多(真正的)通用寄存器,这有助于提高速度。否则,64 位代码只会花费双倍的高速缓存,这使得它在其他架构(如 PPC)中实际上比 32 位代码慢。

The normal gains one get by using 64bit code in general. I haven't found any recent benchmarks, but at the time of x64 introduction, code could run up to 30% faster on 64bit than on 32bit on x86 hardware -- this gap certainly has fallen somehow with the optimizatgions since the time, but is still probably faster.

Also, you benefit of being ablle to transparantly use more than 4GB of memory should you need too.

Note however that the speed gains in 64bit are due to the awfull 32bit legacy ABI: enve a core i7 running in 32 bit has the same 4 general purpose registers (and a couple others) one had in the 80386 chip from 1987. And those mapped 1:1 to the register on the 8086 from the 70's. The 64 bit abi introduces more (real) general purpose registers, and that makes it for the speed gain. Otherwise, 64 bit code simply spends double the cache memory, which makes it, in other architectures, like PPC, be actually slower than 32bit code.

醉态萌生 2024-10-16 19:19:10

我已经在 Linux 上运行 64 位 Python 多年了。没问题,这不是越野车。其中包括 numpy。我不会担心这个。

一个小好处:

Python> sys.maxint
9223372036854775807

不过,我想人们可能会争论这样做是否有任何好处,但一般来说所有 64 位应用程序都是如此。

处理大量数据时您会获得最大的好处。

I've been running 64-bit Python on Linux for years already. No problems, it's not buggy. That includes numpy. I wouldn't worry about that.

One small benefit:

Python> sys.maxint
9223372036854775807

However, I suppose one could argue if there is any benefit to that, but the same goes for all 64-bit apps in general.

You get the most benefit when dealing with very large amounts of data.

荒岛晴空 2024-10-16 19:19:10

我想您会通过 SciPy 和 NumPy 获得性能提升,因为当您向处理器添加更多位时,数字处理和计算会得到极大改善。但我不能确定。

您始终可以并排运行 64 位和 32 位并进行一些比较,我有兴趣了解数字处理方面的测试结果。如果您运行两者的相同版本,则只要您拥有两者所需的模块,代码就可以在两者上正常运行。

I'd imagine you'd get performance increases with SciPy and NumPy since number handling and calculations is what gets vastly improved when you add more bits to a processor. But I can't be sure.

You could always run 64 bit and 32 bit side by side and do some comparisons, I'd be interested to know the results of tests on the number crunching side. And if you're running the same version of both, the code will run on both fine provided you have the modules you need for both.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文