Skip to content

[mypyc] Support the u64 native integer type - #22384

Open
JukkaL wants to merge 1 commit into
masterfrom
mypyc-u64
Open

JukkaL wants to merge 1 commit into
masterfrom
mypyc-u64

Conversation

@JukkaL

@JukkaL JukkaL commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

u64 is an unsigned 64-bit integer. The implementation mostly follows u16 (#22368).

Major differences:

  • Boxing uses PyLong_FromUnsignedLongLong.
  • A u64 may not fit in a short tagged int, so converting to int checks the range and calls CPyTagged_FromUInt64 for large values. Converting from int accepts any non-negative short int directly and uses CPyLong_AsUInt64 for long ints.
  • Add list get/set item primitives that take a u64 index.

Work on mypyc/mypyc#1226.

u64 is an unsigned 64-bit integer. The implementation mostly follows u16
(#22368).

Major differences:
- Boxing uses PyLong_FromUnsignedLongLong.
- A u64 may not fit in a short tagged int, so converting to int checks
  the range and calls CPyTagged_FromUInt64 for large values. Converting
  from int accepts any non-negative short int directly and uses
  CPyLong_AsUInt64 for long ints.
- Add list get/set item primitives that take a u64 index.

Work on mypyc/mypyc#1226.
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Comment on lines +69 to +71
a: u64 = 18446744073709551616
b: u64 = -1
f(18446744073709551616)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i think we're missing an error for the 2^64 literals

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.

2 participants