Propose removal of unused arguments in decode methods #3165
Labels
is-maintenance
Anything that is just internal: Simplifying code, syntax changes, updating docs, speed improvements
needs-discussion
The PR/issue needs more discussion before we can continue
Four of the ten pypdf class filters have, but do not need, a
decode_parms
argument in theirdecode
methods:ASCIIHexDecode
ASCII85Decode
RunLengthDecode
JPXDecode
The rationale for having unused
decode_parms
is so external code has a uniform interface for filters. However, their existence tends to make the code less self explanatory.Benefits of removing these:
Follows the design principle of moving semantics out of comments into code. The function signature will be more self contained, not relying on a comment explaining that one of the arguments is unused.
Coding to external library users who may not even use a uniform interface, complicates our interfaces. We do not use
decode_parms
in functiondecode_stream_data
(which calls most of the filters) when it is unused, suggesting uniformity is not overly useful here.Because all filter class
decode
methods have**kwargs: Any
, any 3rd party code that does break can be fixed simply by ensuringdecode_parms=
is explicitly used when callingdecode
.The text was updated successfully, but these errors were encountered: