[issue40080] Stripping annotations out as a new optimization mode

2021-09-13 Thread Filipe Laíns

Change by Filipe Laíns :


--
nosy: +FFY00

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40080] Stripping annotations out as a new optimization mode

2020-11-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Corrected link:  https://bugs.python.org/issue36466

--
superseder:  -> Adding a way to strip annotations from compiled bytecode

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40080] Stripping annotations out as a new optimization mode

2020-03-26 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Duplicate of https://bugs.python.org/issue3646

This was rejected because it breaks functools.singledispatch(), 
typing.NamedTuple(), and dataclasses.dataclass().  Also the space savings was 
negligible -- typically take much less space than for docstrings because the 
annotations dict consists of pointers to existing objects.

--
nosy: +rhettinger
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40080] Stripping annotations out as a new optimization mode

2020-03-26 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I am -1 to this feature because compared with other optimization levels this 
can have unknown effects on the runtime, especially on dependencies you do not 
control. dataclasses is an example, but much more exist. To support this 
feature we would need also another extension for pyc files (like pyo) but (pyo) 
cannot be used to preserve backwards compatibility. Also, the feature will 
mainly serve to reduce file size, not much to speed up the runtime as any gain 
will be constant at definition time. IMHO the maintenance cost is too high for 
what the value is and it also has some potentially unintended dangerous 
consequences.

--
nosy: +pablogsal

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40080] Stripping annotations out as a new optimization mode

2020-03-26 Thread Batuhan Taskaya


Batuhan Taskaya  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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40080] Stripping annotations out as a new optimization mode

2020-03-26 Thread Eric V. Smith


Eric V. Smith  added the comment:

Note that dataclasses will break without annotations.

--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40080] Stripping annotations out as a new optimization mode

2020-03-26 Thread Batuhan Taskaya


New submission from Batuhan Taskaya :

Just like docstrings, annotations do nothing at runtime for the majority of the 
time. We can just strip out them and gain as much as the docstring optimization 
in bytecode size on a fully annotated repo.

For comparing these two optimizations, I calculated the bytecode weight 
(marshal dumped size of) of each optimization (with a similar implementation to 
the compiler but not exact) over a project which both rich in docstrings and 
annotations. 

Project: https://github.com/Instagram/LibCST

 $ python simple_tester.py LibCST 
Total bytes: 1820086
Total bytes after 629 docstrings (total length of 180333) removed: 1643315
Total bytes after 8859 type annotations removed: 1641594

(I've submitted the script I used to calculate these results.)

--
components: Interpreter Core
files: simple_tester.py
messages: 365118
nosy: BTaskaya
priority: normal
severity: normal
status: open
title: Stripping annotations out as a new optimization mode
type: enhancement
versions: Python 3.9
Added file: https://bugs.python.org/file49004/simple_tester.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40080] Stripping annotations out as a new optimization mode

2020-03-26 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

As an addition, I need to clarify that each optimization applied by its own.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com