X Tutup
The Wayback Machine - https://web.archive.org/web/20260329121430/https://github.com/python/cpython/issues/99077
Skip to content

Optimize away creation of immediately discarded tuples #99077

@markshannon

Description

@markshannon

This comes from a discussion about whether to issue a syntax warning for one-tuples without parentheses.

Regardless of whether a warning is issued, the following code:

    ...
    a, b
    ...

Creates a tuple then discards it.

  LOAD_FAST                0 (a)
  LOAD_FAST                1 (b)
  BUILD_TUPLE              2
  POP_TOP

we could eliminate the creation of the tuple:

  LOAD_FAST                0 (a)
  LOAD_FAST                1 (b)
  POP_TOP
  POP_TOP

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usage

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup