简体   繁体   中英

Using .npy arrays generated in Python3.x in Python2.7 scripts?

I have a number of numpy arrays which I've generated in Python 3.4 scripts and saved, ie

import numpy as np
np.save('array1.npy')

I seem to be running into slight issues trying to use these in Python2.7 in terms of performance (maybe more). Is there a difference?

EDIT: The numpy arrays are multidimensional, with around 1e8 elements. Scripts I run in Python2.7 with .npy files created in Python3.4 take forever/run endlessly. I suspect there are compatibility issues.

In a (now deleted) comment above, it turned out that the OP was comparing a 32 bit version of Python2.7 against a 64 bit version of Python3.4. This is almost certainly the reason for the "performance issues" alluded to in the question.

A (999, 1000, 1000) float64 array, such as the OP is using, will be approximately 8GB in size. Although the OP has 16GB of RAM, a 32 bit process will not be able to address more than 4GB 3GB of memory . Consequently it must either crash, or start swapping and become extremely slow.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM