Databases Reference
In-Depth Information
a replacement interpreter shell that adds features like command history and Tab-
completion for object attributes. It also has tons of additional features for parallel pro‐
cessing, MATLAB-style “notebook” display of graphs, and more.
The best way to explore the features in this topic is with an IPython prompt open,
following along with the examples. Tab-completion alone is worth it, because it lets you
quickly see the attributes of modules and objects. The h5py package is specifically de‐
signed to be “explorable” in this sense. For example, if you want to discover what prop‐
erties and methods exist on the File object (see “Your First HDF5 File” on page 17 ), type
h5py.File. and bang the Tab key:
>>> h5py . File .< TAB >
h5py.File.attrs h5py.File.get h5py.File.name
h5py.File.close h5py.File.id h5py.File.parent
h5py.File.copy h5py.File.items h5py.File.ref
h5py.File.create_dataset h5py.File.iteritems h5py.File.require_dataset
h5py.File.create_group h5py.File.iterkeys h5py.File.require_group
h5py.File.driver h5py.File.itervalues h5py.File.userblock_size
h5py.File.fid h5py.File.keys h5py.File.values
h5py.File.file h5py.File.libver h5py.File.visit
h5py.File.filename h5py.File.mode h5py.File.visititems
h5py.File.flush h5py.File.mro
To get more information on a property or method, use ? after its name:
>>> h5py . File . close ?
Type: instancemethod
Base Class: <type 'instancemethod'>
String Form:<unbound method File.close>
Namespace: Interactive
File: /usr/local/lib/python2.7/dist-packages/h5py/_hl/files.py
Definition: h5py.File.close(self)
Docstring: Close the file. All open objects become invalid
By default, IPython will save the output of your statements in special
hidden variables. This is generally OK, but can be surprising if it hangs
on to an HDF5 object you thought was discarded, or a big array that
eats up memory. You can turn this off by setting the IPython config‐
uration value cache_size to 0. See the docs at http://ipython.org for
more information.
Timing and Optimization
For performance testing, we'll use the timeit module that ships with Python. Examples
using timeit will assume the following import:
>>> from timeit import timeit
Search WWH ::




Custom Search