Skip to content

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

Merged
JukkaL merged 2 commits into
masterfrom
mypyc-u64
Nov 9, 2026
Merged

JukkaL merged 2 commits 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

This comment has been minimized.

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

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

pywin32 (https://github.com/mhammond/pywin32)
  ./pythonwin/pywin/test/_dbgscript.py: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
- version: 2.5.0+dev.5dc284074f99935d394babd1fc555cf0d6405fb9
+ version: 2.5.0+dev.f7a51e891f02e2457bd9e88f6f5a6fcb0743fd1e

@JukkaL
JukkaL merged commit 1e2ea53 into master Nov 9, 2026
26 checks passed
@JukkaL
JukkaL deleted the mypyc-u64 branch November 9, 2026 12:43
hnwg added a commit to hnwg/mypy that referenced this pull request Nov 13, 2026
The u16, u32, u64 and i8 stub classes (added in python#22368, python#22373, python#22384
and python#22447) also lack __abs__.
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