Skip to content

zlib.compress level as keyword argument #70431

Closed

Description

@palaviv
mannequin
BPO 26243
Nosy @Yhg1s, @berkerpeksag, @vadmium, @serhiy-storchaka, @palaviv
PRs
  • bpo-26243: data= is positional-only just on CPython #11754
  • bpo-26243: data= is positional-only just on CPython #11754
  • bpo-26243: data= is positional-only just on CPython #11754
  • Files
  • zlib-compress-level-keyword.patch
  • zlib-compress-level-keyword2.patch
  • zlib-compress-level-keyword3.patch: patch including test
  • zlib_compress_positional_only_data.patch
  • zlib_compress_positional_only_data.patch
  • 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:

    assignee = None
    closed_at = <Date 2016-06-25.19:48:19.446>
    created_at = <Date 2016-01-30.18:41:07.895>
    labels = ['extension-modules', 'type-feature']
    title = 'zlib.compress level as keyword argument'
    updated_at = <Date 2019-02-04.13:45:18.673>
    user = 'https://github.com/palaviv'

    bugs.python.org fields:

    activity = <Date 2019-02-04.13:45:18.673>
    actor = 'lukasz.langa'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-06-25.19:48:19.446>
    closer = 'serhiy.storchaka'
    components = ['Extension Modules']
    creation = <Date 2016-01-30.18:41:07.895>
    creator = 'palaviv'
    dependencies = []
    files = ['41760', '41773', '41797', '43320', '43334']
    hgrepos = []
    issue_num = 26243
    keywords = ['patch']
    message_count = 16.0
    messages = ['259266', '259270', '259332', '259358', '259388', '259452', '259498', '259921', '259925', '259926', '268025', '268144', '269098', '269249', '269250', '269251']
    nosy_count = 7.0
    nosy_names = ['twouters', 'nadeem.vawda', 'python-dev', 'berker.peksag', 'martin.panter', 'serhiy.storchaka', 'palaviv']
    pr_nums = ['11754', '11754', '11754']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue26243'
    versions = ['Python 3.6']

    Activity

    1. palaviv commented on Jan 30, 2016

      palavivmannequin
      MannequinAuthor

      Currently zlib.compress allow only positional arguments. For code readability reasons i think that we should allow the level argument to be keyword argument. Now when someone uses zlib.compress he will be able to do zlib.compess(some_data, level=7) instead of zlib.compress(some_data, 7).

      There is a patch included with the change.

    2. vadmium commented on Jan 30, 2016

      @vadmium
      Member

      Seems like a reasonable enhancement. A couple of points:

      • Watch out for the parameter names. Should it be “bytes” or “data”?
      • Z_DEFAULT_COMPRESSION is -1 not 6 (see bpo-26244)
      • Needs a version changed notice, and probably a What’s New update
    3. added
      type-featureA feature request or enhancement
      and removed
      type-bugAn unexpected behavior, bug, or error
      on Jan 30, 2016
    4. palaviv commented on Feb 1, 2016

      palavivmannequin
      MannequinAuthor

      Thanks for the review.

      1. Changed "bytes" to "data".
      2. Updated Doc as in bpo-26244 (will update the patch if there will be changes there).
      3. Added version changed notice but i don't think there is a need for What's new update.
    5. vadmium commented on Feb 2, 2016

      @vadmium
      Member

      Thanks, it looks good to me. I think “data” is a better name than “bytes”.

      About What’s New, I thought the general idea was to document all enhancements, though I admit this is about as small as they come. There is precedent with the compile() builtin (bpo-1444529, Python 2.6), although there is no indication of kwargs in the main documentation for compile(). But on the other hand, str.split() didn’t get any What’s New entry (bpo-14081, Python 3.3). See also <https://docs.python.org/devguide/committing.html#what-s-new-and-news-entries\>.

    6. berkerpeksag commented on Feb 2, 2016

      @berkerpeksag
      Member

      There is an outdated patch in bpo-16764 for zlib.compress(), zlib.decompress(), zlib.flush() and other functions. Perhaps we can close it as a duplicate of this one.

    7. vadmium commented on Feb 3, 2016

      @vadmium
      Member

      The patch at bpo-16764 has a test case for the new level=... keyword. Perhaps you would like to incorporate/update it :)

    8. palaviv commented on Feb 3, 2016

      palavivmannequin
      MannequinAuthor

      Added the "suggested" test

    9. python-dev commented on Feb 9, 2016

      python-devmannequin
      Mannequin

      New changeset 592db8704d38 by Martin Panter in branch 'default':
      Issue bpo-26243: zlib.compress() keyword argument support by Aviv Palivoda
      https://hg.python.org/cpython/rev/592db8704d38

    10. python-dev commented on Feb 9, 2016

      python-devmannequin
      Mannequin

      New changeset dc758f51b8f5 by Martin Panter in branch 'default':
      bpo-26243: Forgot to update zlib doc strings in Argument Clinic
      https://hg.python.org/cpython/rev/dc758f51b8f5

    11. vadmium commented on Feb 9, 2016

      @vadmium
      Member

      I did add a What’s New entry (I hope nobody minds), and updated the doc strings in the zlib module. Thanks for the work on this Aviv.

    12. serhiy-storchaka commented on Jun 9, 2016

      @serhiy-storchaka
      Member

      The original request was for supporting level as keyword argument. Making the first argument a keyword argument was unintentional side effect (due a to the limitation of argument parsing functions). Now it is possible to support positional-only and keyword arguments in one function (see bpo-26282). Proposed patch makes the first argument positional-only again.

    13. serhiy-storchaka commented on Jun 10, 2016

      @serhiy-storchaka
      Member

      Regenerated for review.

    14. vadmium commented on Jun 23, 2016

      @vadmium
      Member

      The patch (with Berker’s fix) looks okay. Personally, I don’t see a big problem with the first argument also having a keyword name, but I don’t mind if it doesn’t either.

    15. python-dev commented on Jun 25, 2016

      python-devmannequin
      Mannequin

      New changeset 01f82a7a1250 by Serhiy Storchaka in branch 'default':
      Issue bpo-26243: Only the level argument to zlib.compress() is keyword argument
      https://hg.python.org/cpython/rev/01f82a7a1250

    16. python-dev commented on Jun 25, 2016

      python-devmannequin
      Mannequin

      New changeset ab2e7e51869d by Serhiy Storchaka in branch 'default':
      Issue bpo-26243: Correct a wording in docs.
      https://hg.python.org/cpython/rev/ab2e7e51869d

    17. serhiy-storchaka commented on Jun 25, 2016

      @serhiy-storchaka
      Member

      Thanks Berker and Martin.

    18. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      extension-modulesC modules in the Modules dirtype-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions