Skip to content

[mypyc] Compile away NewType type calls#14398

Merged
JelleZijlstra merged 2 commits intopython:masterfrom
ichard26:compile-newtype-type-calls-away
Jan 5, 2023
Merged

[mypyc] Compile away NewType type calls#14398
JelleZijlstra merged 2 commits intopython:masterfrom
ichard26:compile-newtype-type-calls-away

Conversation

@ichard26
Copy link
Copy Markdown
Collaborator

@ichard26 ichard26 commented Jan 5, 2023

For example, here the call to ID is simply a no-op at runtime, returning 1 unchanged.

ID = NewType('ID', int)
person = ID(1)

Resolves mypyc/mypyc#958

For example, here the call to ID is simply a no-op at runtime,
returning 1 unchanged.

    ID = NewType('ID', int)
    person = ID(1)
Comment thread mypyc/irbuild/expression.py Outdated
Copy link
Copy Markdown
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this lgtm!

Copy link
Copy Markdown
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good apart from the suggestion

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@JelleZijlstra JelleZijlstra merged commit ca66805 into python:master Jan 5, 2023
@ichard26 ichard26 deleted the compile-newtype-type-calls-away branch January 5, 2023 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compile calls to NewType types into no-ops

4 participants