Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not create a temporary array when obj is not specified in create_array #339

Merged
merged 2 commits into from
Mar 5, 2014

Conversation

FrancescAlted
Copy link
Member

This is a solution for avoiding the creation of temporaries when creating a regular Array object when specifying the atom and shape only. Fixes #337.

Memory consumption is now similar to h5py, and by running the examples in this post (but with n = 50000 to make things a bit faster), we get:

with h5py:

$ rm test.h5; time python benchmark-h5py.py
Creating HDF5 file...
0 1 2 3 4 5 6 7 8 9 Elapsed: 0.02 s
Bandwidth: 77.6 MB/s

real    0m4.284s
user    0m3.854s
sys     0m0.420s

with PyTables:

$ rm test.h5; time python benchmark-tables.py
Creating HDF5 file...
0 1 2 3 4 5 6 7 8 9 Elapsed: 0.01 s
Bandwidth: 225.7 MB/s

real    0m3.825s
user    0m3.283s
sys     0m0.535s

which is pretty much faster than h5py (don't know exactly why).

@avalentino avalentino merged commit 1da0f0b into PyTables:develop Mar 5, 2014
@avalentino avalentino added this to the 3.2 milestone Mar 5, 2014
# array fast and without memory consumption
dflt = numpy.zeros((), dtype=atom.dtype)
obj = numpy.ndarray(shape, dtype=atom.dtype, buffer=dflt,
strides=(0,)*len(shape))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Is this a known numpy bug?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Known bug? Strides = (0, ...) are well supported in NumPy, although not advertised a lot.

@avalentino avalentino modified the milestones: 3.1.1, 3.2 Mar 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants