We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@final
Bug Report
I am trying to compile a module with @final types. This does not seem possible at the moment with mypyc.
mypyc
Actual source: https://github.com/dry-python/returns/blob/master/returns/result.py#L312
To Reproduce
from typing_extensions import final class Base(object): """Can be sub-classed.""" @final class Child(Base): """Final instance."""
When mypyc is used on top of this code, this happens:
» mypyc ex.py ex.py:9: error: Non-extension classes may not inherit from extension classes
As I understand, mypyc treats @final as a regular decorator and then makes Child a non-exntesion class. And this does not seem correct to me.
Child
Expected Behavior
I would expect this code to compile without any warnings. And @final should be treated the same way mypy does with regular python code.
mypy
python
0.790
The text was updated successfully, but these errors were encountered:
still happening in 1.0.9 even I think it would be benefical for codegen to apply optimization
Sorry, something went wrong.
[mypyc] Optimize calls to final classes (#17886)
cbd96f9
Fixes #9612 This change allows to gain more efficiency where classes are annotated with `@final` bypassing entirely the vtable for method calls and property accessors. For example: In ```python @Final class Vector: __slots__ = ("_x", "_y") def __init__(self, x: i32, y: i32) -> None: self._x = x self._y = y @Property def y(self) -> i32: return self._y def test_vector() -> None: v3 = Vector(1, 2) assert v3.y == 2 ``` The call will produce: ```c ... cpy_r_r6 = CPyDef_Vector___y(cpy_r_r0); ... ``` Instead of: ```c ... cpy_r_r1 = CPY_GET_ATTR(cpy_r_r0, CPyType_Vector, 2, farm_rush___engine___vectors2___VectorObject, int32_t); /* y */ ... ``` (which uses vtable)
Successfully merging a pull request may close this issue.
Bug Report
I am trying to compile a module with
@final
types.This does not seem possible at the moment with
mypyc
.Actual source: https://github.com/dry-python/returns/blob/master/returns/result.py#L312
To Reproduce
When
mypyc
is used on top of this code, this happens:As I understand,
mypyc
treats@final
as a regular decorator and then makesChild
a non-exntesion class.And this does not seem correct to me.
Expected Behavior
I would expect this code to compile without any warnings.
And
@final
should be treated the same waymypy
does with regularpython
code.0.790
The text was updated successfully, but these errors were encountered: