Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.1k
[mypyc] Allow per-class free list to be used with inheritance#19790
New issue
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
It's still unsupported if interpreted subclasses are allowed.
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -3802,7 +3802,7 @@ from mypy_extensions import mypyc_attr | ||
| a = [] | ||
| @mypyc_attr(free_list_len=1) | ||
| class Foo: | ||
| def __init__(self, x: int) -> None: | ||
| self.x = x | ||
| @@ -3830,3 +3830,64 @@ def test_alloc() -> None: | ||
| y = Foo(5) | ||
| assert x.x == 4 | ||
| assert y.x == 5 | ||
| @mypyc_attr(free_list_len=1) | ||
| class Base: | ||
| def __init__(self, x: str) -> None: | ||
| self.x = x | ||
| class Deriv(Base): | ||
| def __init__(self, x: str, y: str) -> None: | ||
| super().__init__(x) | ||
| self.y = y | ||
| @mypyc_attr(free_list_len=1) | ||
| class Deriv2(Base): | ||
| def __init__(self, x: str, y: str) -> None: | ||
| super().__init__(x) | ||
| self.y = y | ||
| def test_inheritance() -> None: | ||
| x: Base | None | ||
| y: Base | None | ||
p-sawicki marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| x = Base('x' + str()) | ||
| y = Base('y' + str()) | ||
| y = None | ||
| d = Deriv('a' + str(), 'b' + str()) | ||
| assert type(d) is Deriv | ||
| assert d.x == 'a' | ||
| assert d.y == 'b' | ||
| assert x.x == 'x' | ||
| y = Base('z' + str()) | ||
| assert d.x == 'a' | ||
| assert d.y == 'b' | ||
| assert y.x == 'z' | ||
| x = None | ||
| y = None | ||
| def test_inheritance_2() -> None: | ||
| x: Base | None | ||
| y: Base | None | ||
p-sawicki marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| d: Deriv2 | None | ||
| x = Base('x' + str()) | ||
| y = Base('y' + str()) | ||
| y = None | ||
| d = Deriv2('a' + str(), 'b' + str()) | ||
| assert type(d) is Deriv2 | ||
| assert d.x == 'a' | ||
| assert d.y == 'b' | ||
| assert x.x == 'x' | ||
| d = None | ||
| d = Deriv2('c' + str(), 'd' + str()) | ||
| assert type(d) is Deriv2 | ||
| assert d.x == 'c' | ||
| assert d.y == 'd' | ||
| assert x.x == 'x' | ||
| y = Base('z' + str()) | ||
| assert type(y) is Base | ||
| assert d.x == 'c' | ||
| assert d.y == 'd' | ||
| assert y.x == 'z' | ||
| x = None | ||
| y = None | ||
| d = None | ||
Uh oh!
There was an error while loading.Please reload this page.