Skip to content

Defaults for functions should be emitted as a constant tuple when possible #105

Closed

Description

@OddBloke

Currently we emit instructions to build a tuple, but the contents are constant, so we can just emit the constructed tuple.

Activity

  1. self-assigned this
    on Aug 29, 2018
  2. OddBloke commented on Aug 29, 2018

    @OddBloke
    CollaboratorAuthor

    As part of the next step of #100 I've implemented a tuple bytecode constant, so I'll do this once that lands.

  3. changed the title [-]Defaults for functions should be emitted as a constant tuple[/-] [+]Defaults for functions should be emitted as a constant tuple when possible[/+] on Aug 30, 2018
  4. OddBloke commented on Aug 30, 2018

    @OddBloke
    CollaboratorAuthor

    This isn't actually possible to do in all cases; we can only do it when the defaults themselves are all constants.

    As this isn't as trivial as anticipated, I'm not going to do it in the near-term.

  5. removed their assignment
    on Aug 30, 2018
  6. youknowone commented on Oct 6, 2026

    @youknowone
    Member

    Constant function defaults are emitted as a single LOAD_CONST tuple (e.g. (1, 2)) rather than being built at runtime. Closing.

    — commented by Grok 4.6

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions