gpt4 book ai didi

Python 速度 32 v 64 位 Windows 问题

转载 作者:可可西里 更新时间:2023-11-01 10:01:27 24 4
gpt4 key购买 nike

在 32 位 Windows 7 和 64 位 Windows Server 2008 之间移动应用程序时,我一直遇到性能问题,两者都具有类似的处理器。我写了一个简单的程序来测试内存分配性能以查看差异。它表明在 64 位上制作列表花费的时间几乎是 32 位窗口的 10 倍。在 32 上使用 python 2.6.5,在 64 上使用 2.6.6。可能导致问题的原因是什么?我写了一个小的“c”程序来做同样的事情,它显示 64 位服务器运行得更快。到底出了什么问题?

#silly python memory allocation test
from datetime import datetime
import random

d = datetime.now()
listo = [1] * 300000
del listo
print datetime.now()-d
d = datetime.now()
listo = [1] * 3000000
del listo
print datetime.now()-d
d = datetime.now()
listo = [1] * 30000000
print datetime.now()-d

结果 32

0:00:00.002000
0:00:00.024000
0:00:00.166000

结果为 64

0:00:00.031000
0:00:00.156000
0:00:02.672000

64 位 Windows 上的 Python 和内存性能是否存在一些突出的问题?

64 位 Windows 2008 R2 服务器设置

4 CPU, 16GB 内存, 20GB C 盘, 10GB/s Network Xeon X5570 @ 2.93GHz

32 台 Windows 7 电脑

2 CPU, 2GB 内存, 500gb C 盘, 1 Gb/s 网络 Core 2 duo @ 3.00ghz

最佳答案

我不知道为什么这么长,但你应该期待更多的时间,因为在这个例子中,程序在 64 位模式下分配了两倍的内存,因为 python 使用 32/64 位指针在其列表中。

当您仍在使用 32 位数据类型时,这在 C 中可能会有所不同。

关于Python 速度 32 v 64 位 Windows 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5387472/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com