Names side by side¶
The same members, spelled for each language. C++ uses the names the header
declares; Python uses snake_case, makes the four accessors periodic, lims,
n_cells and cellsize read-only properties, gives the object count as
len(grid), and returns numpy arrays where C++ returns vectors. Each member
is documented in the C++ reference and the
Python reference.
In the table, X, Y, Z are the coordinates of one point and QX, QY, QZ the
coordinate arrays of a batch of query points; index is one object index and
indices an array of them.
C++ |
Python |
what it is |
|---|---|---|
|
|
C++ passes limits and periodic axes in a |
|
— |
the same from three pointers to |
|
|
the same from |
|
— |
an empty grid, to assign to later |
|
|
objects in the grid, removed ones excluded |
|
|
the box; a 3×2 array in Python |
|
|
cells per axis; a tuple in Python |
|
|
the cell side used |
|
|
periodic flag per axis; a tuple in Python |
|
|
whether an index names an object in the grid |
|
|
whether a point lies in the box |
|
|
the nearest object |
|
|
its batches |
|
|
the N nearest |
|
|
its batches: |
|
|
every object in a ball or shell |
|
|
its batches, returning a |
|
|
how many |
|
|
its batches |
|
|
the threads a batch may use; −1 for every core |
|
— |
the number given |
|
|
|
|
|
linear index of a point’s cell |
|
|
coordinates of a point’s cell |
|
|
the objects in a point’s cell |
|
|
add an object; returns its index |
|
|
remove an object |
copy constructor and assignment |
|
an independent copy |
move constructor and assignment |
— |
transfer a grid without copying |
— |
|
object count, cells, cell side and periodic axes |
|
|
the version built |
|
|
every error the grid raises; a |
|
|
an index out of range or removed; also a built-in |
|
|
out of memory |
What differs¶
The results and the errors are the same in both languages; only their types differ.
Types. Indices are a
std::vector<unsigned int>in C++ and auint32array in Python; batch counts astd::vector<std::uint64_t>and anint64array; flags astd::vector<std::uint8_t>of 0 and 1 and aboolarray; batch offsetsstd::uint64_tandint64. Python arrays own their data and stay valid after the grid is gone.Reusing memory. C++ queries that return a container (all but
get_objectsInCell) also have a form writing into one passed after the other arguments, beforeworkerswhere there is one; Python batches with a result of known shape takeout=. See the guide.Negative numbers. The unsigned C++ types cannot express them; in Python a negative index raises
meshsearch.IndexError(andis_aliveanswersFalse), and a negativenraisesmeshsearch.Error.Messages. A failed Python batch names the query that failed.