Skip to content

native: a generalized module-level value is annotated with Any - #167

Merged
simontreanor merged 1 commit into
mainfrom
native-generic-value-annotations
Sep 28, 2026
Merged

simontreanor merged 1 commit into
mainfrom
native-generic-value-annotations

Conversation

@simontreanor

Copy link
Copy Markdown
Owner

let emptyBoard = Map.empty has type Map 'k 'v. The annotator couldn't spell that type, so the value went unannotated, and mypyc stopped with "Cannot determine type" when another module read it. This is the case #166 missed.

  • A module-level value now spells its type variables as Any (dict[Any, Any]), and the module imports Any when it needs it.
  • Function parameters still leave a type variable unannotated, since Any there would hide a real signature.

With this, a real multi-module program compiles with mypyc on Windows (MSVC, CPython 3.14), and its output matches plain Python. Its move-generation benchmark runs about 1.5x faster compiled. ROADMAP records these timings.

Test: native_annotates_module_level_values_for_other_modules now covers a generic value too.

`let emptyBoard = Map.empty` has type `Map 'k 'v`, which the annotator
could not spell, so the value went unannotated and mypyc stopped on
another module's read of it ("Cannot determine type"). A module-level
value now spells its type variables as `Any` (`dict[Any, Any]`), and the
module imports `Any` when it needs to. Function parameters still leave a
type variable unannotated.

ROADMAP records the first compiled timings of a real program.
@simontreanor
simontreanor merged commit 59be391 into main Sep 28, 2026
20 checks passed
@simontreanor
simontreanor deleted the native-generic-value-annotations branch September 28, 2026 11:39
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.

1 participant