8000 Unpacker: add tell() by jfolz · Pull Request #227 · msgpack/msgpack-python · GitHub
[go: up one dir, main page]

Skip to content

Unpacker: add tell() #227

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

Merged
merged 1 commit into from
Apr 29, 2017
Merged

Unpacker: add tell() #227

merged 1 commit into from
Apr 29, 2017

Conversation

jfolz
Copy link
Contributor
@jfolz jfolz commented Apr 29, 2017

There seems to be a demand for tracking offset (e.g., for indexing) while unpacking from stream. Before 1.0, it is suggested to use write_bytes for that purpose. Since it was really easy and a lot more efficient, this PR adds a tell() method to Unpacker.

@@ -314,6 +315,7 @@ cdef class Unpacker(object):
cdef object object_hook, object_pairs_hook, list_hook, ext_hook
cdef object encoding, unicode_errors
cdef Py_ssize_t max_buffer_size
cdef uint64_t stream_offset
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Py_ssize_t may be 32bit, which is a bit small even today. 16 Exabyte should be plenty for some time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be good for 30+ years (if you can unpack continuously at 16GB/s ;))

@methane methane merged commit a8d9162 into msgpack:master Apr 29, 2017
@jfolz jfolz deleted the feature/tell branch April 30, 2017 09:36
@enkore
Copy link
enkore commented Apr 30, 2017

Thanks! This way is indeed a lot simpler internally and externally than what I tried in my patch :)

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
0