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

Make Struct object for pointer_to_nested_list #9

Merged
merged 1 commit into from
Nov 20, 2018

Conversation

jakirkham
Copy link
Owner

Instead of calling struct.unpack using fmt within pointer_to_nested_list, make a Struct object and pass its unpack method into pointer_to_nested_list. As struct.unpack ends up constructing a Struct object anyways, this ends up being lower overhead as the same Struct object can be reused for all conversions of bytes from the buffer into Python values. Benchmarking of the different unpack cases verifies this improves the runtime over 2x.

Benchmarking cybuffer's tolist with and without this changes also shows a significant improvement. With this change, tolists runtime is roughly halved. Though it remains roughly 4x slower than NumPy, this is a significant performance improvement. Should also be a good point to build on for further performance improvements.

Instead of calling `struct.unpack` using `fmt` within
`pointer_to_nested_list`, make a `Struct` object and pass its `unpack`
method into `pointer_to_nested_list`. As `struct.unpack` ends up
constructing a `Struct` object anyways, this ends up being lower
overhead as the same `Struct` object can be reused for all conversions
of `bytes` from the buffer into Python values. Benchmarking of the
different `unpack` cases verifies this improves the runtime over 2x.

Benchmarking `cybuffer`'s `tolist` with and without this changes also
shows a significant improvement. With this change, `tolist`s runtime is
roughly halved. Though it remains roughly 4x slower than NumPy, this is
a significant performance improvement. Should also be a good point to
build on for further performance improvements.
@jakirkham jakirkham merged commit e477a6b into master Nov 20, 2018
@jakirkham jakirkham deleted the use_Struct_object branch November 20, 2018 21:29
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.

None yet

1 participant