Comments (5)
The difficulty with disallowing a dynamic type is we do want to allow it sometimes. We have things like CheckedDict[str, Set[...]]
. In this case other type checkers happily see the Set[...]
type and CheckedDict
as an alias for Dict
and enforce the appropriate types. But we just see Set[...]
as dynamic, and turn it into a CheckedDict[str, object]
.
So I think disallowing it ends up being worse than making it work. I have a fix which would make this work for CheckedDict
by getting rid of __new__
so that our allocation will go through TP_ALLOC
which takes a type descriptor. Unfortunately if we ever want a generic type which is immutable (which would presumably take arguments) then we'll run into this again.
There's probably a couple of possible solutions for that. One might be to add a way to invoke __new__
that takes the type descriptor and passes the resolved type in as the 1st argument (i.e. a TP_NEW opcode). What might be better would be adding an opcode which turns a type descriptor into the underlying type. Then we could emit the __new__
call with the compiler known type instead of emitting the various loads and binary subscrs required to produce the type. That might not require any specialization of the __new__
handling - we could just use that to emit any generic type references.
from cinder.
There is no dynamic
at runtime, dynamic is purely a compiler construct. If a dynamic type ends up in the bytecode, it gets translated to object
.
I think probably what we want here is the static type error on trying to make a CheckedDict with dynamic type as key or value type.
from cinder.
The problem here is that we think we want to create a CheckedDict[str, dynamic]
because we don't know what C resolves to. But we then call CheckedDict.__new__(CheckedDict[str, C])
to create the instance of it.
from cinder.
Is chkdict[str, object].__new__
the same as CheckedDict.__new__
(the right constructor)? We were wondering how object
got involved, as opposed to C
or dynamic
.
from cinder.
This is now fixed, we'll make a CheckedDict
which respects what the compiler things the type is instead of the runtime provided type. Per the discussion above there'll be more work in the future though.
from cinder.
Related Issues (20)
- Type errors in deltablue_static HOT 3
- Build error: C++20 ambiguous & forming offset 4 is out of the bounds HOT 1
- fannkuch benchmark & implicit returns
- type aliases no longer work? HOT 2
- Error compiling with `--with-lto` -- undefined reference to `vtable for strictmod::objects::StrictExceptionObject`
- Cannot install insightface by python-cinder HOT 2
- RuntimeError: Failed to initialize CinderX HOT 3
- could not find symtab HOT 4
- take infinite loops into account in type narrowing HOT 5
- A test in `test_static` should catch `AssertionError` rather than `TypeError` HOT 4
- add README for benchmarks HOT 7
- questions about CheckedDict and unknown types HOT 5
- Benchmark Cinder vs. Cpython performance; improve pipeline and performance of the Cinder build HOT 15
- 15 failing tests fail when running `make test` on a Mac HOT 1
- build error: listnode.gcda missing-profile HOT 3
- Cinder vs. Python 3.11 HOT 9
- can't compare double to Literal HOT 1
- nonsensical TypeError from "-X jit -m compile --static" HOT 3
- No pattern found for opcode Fadd: Xxr HOT 2
- HPy support HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cinder.