[issue40080] Stripping annotations out as a new optimization mode

Batuhan Taskaya report at bugs.python.org
Thu Mar 26 20:18:55 EDT 2020


Batuhan Taskaya <batuhanosmantaskaya at gmail.com> added the comment:

> Note that dataclasses will break without annotations.

Yes, that is also affecting this simple tester script. There is no alternative to value-less annotated assignment.

I don't think this is preferable but just for information, these are the results for keeping AnnAssign nodes but just removing their annotation

    def visit_AnnAssign(self, node):
        self.stats += 1
        node.annotation = ast.copy_location(ast.Constant(value=None), node.annotation)
        return node

Total bytes: 1820086
Total bytes after 629 docstrings (total length of 180333) removed: 1643315
Total bytes after 8859 type annotations removed: 1664649

This way we can still support dataclasses but still gain as close as before

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40080>
_______________________________________


More information about the Python-bugs-list mailing list