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
zlib decompress; uncontrollable memory usage #33910
Comments
zlib's decompress method will allocate as much memory as is In experimentation, I seen decompress generate output that is These characteristics may make the decompress method unsuitable for This patch adds a new method, decompress_incremental, which allows It is possible to solve this problem without a patch: (Ive not been able to test the documentation patch; I hope its ok) (This patch also includes the change from Patch bpo-103748) |
Rather than introducing a new method, why not just add an optional maxlen argument to .decompress(). I think the changes would be:
Do you want to make those changes and resubmit the patch? |
I did consider that.... An extra change that you didnt mention is the need for a different return value. Currently .decompress() always returns a string. The new method in my patch returns a tuple containing the same string, and an integer specifying how many bytes were consumed from the input. Overloading return values based on an optional parameter seems a little hairy to me, but I would be happy to change the patch if that is your preferred option. I also considered (and rejected) the possibility of adding an optional max-size argument to .decompress() as you suggest, but raising an exception if this limit is exceeded. This avoids the need for an extra return value, but looses out on flexibility. |
Doesn't .unused_data serve much the same purpose, though? |
We can reuse .unused_data without introducing an ambiguity. I will prepare a patch that uses a new attribute .unconsumed_tail |
Waaah - that last comment should be 'cant' not 'can' |
New patch implementing a new optional parameter to .decompress, and a new attribute .unconsumed_tail |
Logged In: YES as a side note. I believe I implemented a python workaround see the mojonation project on sourceforge if you're Regardless, I like thie idea of this patch. It would be |
Logged In: YES I've let this patch gather dust long enough. Unassigning so |
Logged In: YES The patch looks good to me; I recommend to approve it. |
Logged In: YES Since this patch has been sitting around for such a long |
Logged In: YES I volunteer to update it |
Logged In: YES I have integrated this patch into the latest Python CVS tree,
It doesn't look like I can submit an attachment with this |
Logged In: YES The patch from titus (added by loewis) looks good |
2 similar comments
Logged In: YES The patch from titus (added by loewis) looks good |
Logged In: YES The patch from titus (added by loewis) looks good |
Logged In: YES Indeed, looks like a good feature. Patch is fine with a few |
Logged In: YES Committed with mods as |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: