Conversation
`type(int) is type`, `isinstance(int, type)`, `issubclass(bool, int)`, `int.__mro__` / `__name__` / `__bases__` / `__qualname__` / `__module__` all behave like CPython now. Builtin types stay as `*object.BuiltinFunc` under the hood (no dispatch core changes); `wireBuiltinTypeAttrs` decorates them with class-shape metadata, and `type()` is a self- referential BuiltinFunc that returns the registered type for builtins. Subclass arithmetic (`class N(int): ...`) is V2 part 2, scheduled for v0.1.3. typing.get_type_hints fallout is V2 part 3, scheduled for v0.1.4. Fixture 348 covers the surface across every builtin type. The pre-V2 281_builtins.expected.txt had captured a buggy goipy answer for `issubclass(bool, int)`; regenerated from CPython. Spec: notes/Spec/1500/1543_goipy_v0102_builtin_types_surface.md Roadmap: notes/Spec/1500/1541_goipy_v01x_roadmap.md (V2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
V2 part 1 of 3: builtin types (
int,str,bool,float,list,tuple,dict,set,frozenset,bytes,bytearray,complex,memoryview,type) now satisfytype(int) is type,isinstance(int, type),issubclass(bool, int), and expose__mro__/__name__/__bases__/__qualname__/__module__.Surface only — subclass arithmetic (
class N(int): ...) is V2 part 2 (v0.1.3); typing fallout is V2 part 3 (v0.1.4).vm/ops.go:builtinTypeNames,builtinTypeBases,isBuiltinTypeName,isBuiltinSubclass.vm/builtins.go:wireBuiltinTypeAttrsdecorates each builtin-type BuiltinFunc with class-shape attrs;type()is a self-referential BuiltinFunc;isinstanceandissubclasslearn the BuiltinFunc-as-class form.internal/testdata/348_builtin_types_surface.pycoverstype(x) is T,type(T) is type,isinstance(T, type),issubclassmatrix, name/qualname/module,__mro__,__bases__.internal/testdata/281_builtins.expected.txtregenerated — it had captured pre-V2issubclass(bool, int) → False; now correctly True.Spec:
notes/Spec/1500/1543_goipy_v0102_builtin_types_surface.mdRoadmap:
notes/Spec/1500/1541_goipy_v01x_roadmap.md(V2)Test plan
go build ./...cleango test ./...green (including 348 + the regenerated 281 expected)python3.14 -m compileall -b internal/testdata/348_builtin_types_surface.py && go run ./cmd/goipy internal/testdata/348_builtin_types_surface.pycmatches CPython output