mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-03 04:21:13 +00:00
[Python] (scalar) vector reading speedup via numpy (#4390)
* Add numpy accessor to python flatbuffers scalar vectors * Update python tests to test numpy vector accessor * Update appveyor CI to run Python tests, save generated code as artifact * Update example generated python code * Add numpy info to python usage docs * Update test schema and python tests w/ multi-byte vector * did not mean to push profiling code * adding float64 numpy tests
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
89a68942ac
commit
3282a84e30
@@ -101,6 +101,18 @@ class Table(object):
|
||||
return d
|
||||
return self.Get(validator_flags, self.Pos + off)
|
||||
|
||||
def GetVectorAsNumpy(self, flags, off):
|
||||
"""
|
||||
GetVectorAsNumpy returns the vector that starts at `Vector(off)`
|
||||
as a numpy array with the type specified by `flags`. The array is
|
||||
a `view` into Bytes, so modifying the returned array will
|
||||
modify Bytes in place.
|
||||
"""
|
||||
offset = self.Vector(off)
|
||||
length = self.VectorLen(off) # TODO: length accounts for bytewidth, right?
|
||||
numpy_dtype = N.to_numpy_type(flags)
|
||||
return encode.GetVectorAsNumpy(numpy_dtype, self.Bytes, length, offset)
|
||||
|
||||
def GetVOffsetTSlot(self, slot, d):
|
||||
"""
|
||||
GetVOffsetTSlot retrieves the VOffsetT that the given vtable location
|
||||
|
||||
Reference in New Issue
Block a user