Set default read_size to 1 for backwards compatibility#275
Set default read_size to 1 for backwards compatibility#275agronholm merged 6 commits intoagronholm:masterfrom
Conversation
The buffered reads introduced in 5.8.0 could cause issues when code needs to access the stream position after decoding. This changes the default back to 1 (matching 5.7.1 behavior) while allowing users to opt-in to faster decoding by passing read_size=4096. Implementation details: - Use function pointer dispatch to eliminate runtime checks for read_size=1 - Skip buffer allocation entirely for unbuffered path - Add read_size parameter to load() and loads() for API completeness
|
Note: when you mark those check boxes, don't add extra spaces around the X as it prevents them from being rendered as checkboxes on the github website. |
| // Forward declarations for read dispatch functions | ||
| static int fp_read_unbuffered(CBORDecoderObject *, char *, Py_ssize_t); | ||
| static int fp_read_buffered(CBORDecoderObject *, char *, Py_ssize_t); |
There was a problem hiding this comment.
Do you suppose the run-time check is costly enough to warrant this?
agronholm
left a comment
There was a problem hiding this comment.
I think the read-ahead warrants a mention in the docs, as the optimization now requires an opt-in.
|
@andreer Are you up to the task of adding the appropriate documentation paragraph? What are your intentions? |
|
@andreer ping - do you intend to finish this PR, or would you like me to take over? |
|
For anyone watching, I think I'll finish the code and docs myself in a few days. |
agronholm
left a comment
There was a problem hiding this comment.
I've added a docs section to explain how to tune the performance.
|
Thanks! |
Changes
Set default read_size to 1.
Fixes #272
The buffered reads introduced in 5.8.0 could cause issues when code needs to access the stream position after decoding. This changes the default back to 1 (matching 5.7.1 behavior) while still allowing users to opt-in to faster decoding by passing read_size=4096.
Implementation details:
Checklist
If this is a user-facing code change, like a bugfix or a new feature, please ensure that
you've fulfilled the following conditions (where applicable):
tests/) which would fail without your patchdocs/), in case of behavior changes or newfeatures
docs/versionhistory.rst).