Hacker News new | ask | show | jobs
by apu 5303 days ago
Not just space, but speed as well. I've often noted significant speedups in many operations by switching to array.array. In some cases, the speedups are comparable to or even slightly better than using numpy (which is much more heavy-weight).
1 comments

Out of curiosity, what are you doing for which arrays are more suited than NumPy?

I've been using NumPy for a while now, and I've literally never had a reason to use array.array where NumPy arrays have worked.

I find numpy too heavy weight for a lot of stuff and also not very good for communication/interchange with other programs. For a lot of my work, I often need to write data files to disk (for C programs to use) or mmap'ed files for concurrent access. In these situations, the fact that array.array offers precise data alignment rules and toString() and toFile() methods that are actually sane, I end up using it instead of numpy.

Of course, if I do significant computations in my python program itself, I just use numpy.