GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Backport set and dict comprehensions · Issue #46586 · python/cpython

Backport set and dict comprehensions #46586

New issue
Copy link
New issue
Copy link
Closed
Closed
Backport set and dict comprehensions#46586
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@brettcannon
brettcannon
opened on Mar 17, 2008
Issue body actions
BPO 2333
Nosy @brettcannon, @mdickinson, @avassalotti, @ezio-melotti
Dependencies
  • bpo-2335: Backport set literals
  • Files
  • backport_dict_and_set_comprehension.diff
  • patch_failure.log: Output of attempt to apply patch.
  • set_and_dict_comprehensions.diff
  • 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 2010-01-11.22:36:41.905>
    created_at = <Date 2008-03-17.17:37:33.157>
    labels = ['interpreter-core', 'type-bug']
    title = 'Backport set and dict comprehensions'
    updated_at = <Date 2012-11-14.09:00:10.725>
    user = 'https://github.com/brettcannon'

    bugs.python.org fields:

    activity = <Date 2012-11-14.09:00:10.725>
    actor = 'fossilet'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-01-11.22:36:41.905>
    closer = 'alexandre.vassalotti'
    components = ['Interpreter Core']
    creation = <Date 2008-03-17.17:37:33.157>
    creator = 'brett.cannon'
    dependencies = ['2335']
    files = ['14661', '14670', '27981']
    hgrepos = []
    issue_num = 2333
    keywords = ['patch', '26backport']
    message_count = 11.0
    messages = ['63690', '91338', '91367', '91368', '91369', '96257', '97611', '112812', '175539', '175541', '175554']
    nosy_count = 6.0
    nosy_names = ['brett.cannon', 'mark.dickinson', 'fossilet', 'alexandre.vassalotti', 'ezio.melotti', 'metal']
    pr_nums = []
    priority = 'critical'
    resolution = 'accepted'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue2333'
    versions = ['Python 2.7']

    Activity

    1. brettcannon commented on Mar 17, 2008

      @brettcannon
      brettcannon
      on Mar 17, 2008
      MemberAuthor
      More actions

      Dict comprehensions need to be backported.

    2. brettcannon
      added
      release-blocker
      interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
      type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
      and removed
      release-blocker
      on Mar 17, 2008
    3. avassalotti commented on Aug 5, 2009

      @avassalotti
      avassalotti
      on Aug 5, 2009
      Member
      More actions

      Here is a patch to backport dict and set comprehensions to the trunk.

      The patch preserves the Python 3.x's syntax and semantics of the
      feature. Although this makes dict and set comprehensions is inconsistent
      with list comprehension, I believe this is reasonable since the backport
      aimed to improve the compatibility of Python 2.x with Python 3.x.

      The patch also adds support for dict and set comprehensions to the
      'compiler' package. However, the support is quirky and use the list
      comprehension semantics of Python 2.x. This allowed me to keep the patch
      simple and to keep myself sane ;-).

      Finally, the patch changes the name of the following syntax nodes:
      'gen_expr', 'gen_iter', 'gen_if', and 'testlist_gexp'. I don't know if
      we have compatibility requirements for this; so I don't know if this is
      an issue.

    4. avassalotti
      changed the title [-]Backport dict comprehensions[/-] [+]Backport set and dict comprehensions[/+] on Aug 5, 2009
    5. mdickinson commented on Aug 6, 2009

      @mdickinson
      mdickinson
      on Aug 6, 2009
      Member
      More actions

      Alexandre, I can't get this to apply cleanly to my svn trunk checkout
      (r74328) (see attached log). Am I doing something stupid?

    6. avassalotti commented on Aug 6, 2009

      @avassalotti
      avassalotti
      on Aug 6, 2009
      Member
      More actions

      You need to apply the set literal patch I posted in bpo-2335 first.

    7. mdickinson commented on Aug 6, 2009

      @mdickinson
      mdickinson
      on Aug 6, 2009
      Member
      More actions

      Ah, that works. Thanks! (I'll pay more attention to the tracker
      Dependencies field in future.)

    8. avassalotti commented on Dec 11, 2009

      @avassalotti
      avassalotti
      on Dec 11, 2009
      Member
      More actions

      If there are no objections, I will commit this patch later this week
      after issue bpo-2335.

    9. avassalotti commented on Jan 11, 2010

      @avassalotti
      avassalotti
      on Jan 11, 2010
      Member
      More actions

      Committed in r77422.

    10. avassalotti
      closed this as completedon Jan 11, 2010
    11. metal commented on Aug 4, 2010

      @metal
      metalmannequin
      on Aug 4, 2010
      Mannequin
      More actions

      How about fixing set.__repr__ ?

    12. fossilet commented on Nov 14, 2012

      @fossilet
      fossiletmannequin
      on Nov 14, 2012
      Mannequin
      More actions

      Great they are backported to 2.7. Dictionary and set comprehensions are not documented in the tutorial of 2.7, though they are in the language reference. Is it OK to add these to the tutorial? I've uploaded a patch.

    13. ezio-melotti commented on Nov 14, 2012

      @ezio-melotti
      ezio-melotti
      on Nov 14, 2012
      Member
      More actions

      Is it OK to add these to the tutorial? I've uploaded a patch.

      Yes, but please create a new issue.

      How about fixing set.__repr__ ?

      Is it broken?

    14. fossilet commented on Nov 14, 2012

      @fossilet
      fossiletmannequin
      on Nov 14, 2012
      Mannequin
      More actions

      I think metal means that the different ways set is repr'd in 2.7 and 3.

      In 2.7:

      In [9]: a = {x for x in 'abracadabra' if x not in 'abc'}

      In [10]: repr(a)
      Out[10]: "set(['r', 'd'])"

      In 3.2:
      In [6]: a = {x for x in 'abracadabra' if x not in 'abc'}

      In [7]: repr(a)
      Out[7]: "{'r', 'd'}"

      We were saying not changing __repr__ in bpo-2335.

    15. ezio-melotti
      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

      interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions

        You are visitor 01402503 — GeezerVison does not store the pages you look up.
        Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.