danielgtaylor / danielgtaylor/python-betterproto
Optimize dataclasses with __slots__
- Lingua principale
- Python
- Stelle
- 1.8k
- Fork
- 234
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
[Adding \_\_slots\_\_ to a class](https://stackoverflow.com/questions/472000/usage-of-slots) improves memory usage and performance of attribute access, at the expense of not being able to set arbitrary attributes on the resulting objects.
[This project](https://github.com/starhel/dataslots/blob/master/dataslots/__init__.py) demonstrates how dataclasses can be augmented to use __slots__, whilst still having class attributes set (normally adding the __slots__ attribute to a class definition would cause an error with dataclassess that declare default values).
Making generated dataclasses use slots in this way would be a small breaking change, though I don't see how it could be too inconvenient to work with, and I expect the performance improvement would be worthwhile.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Non è indicato alcun file del repository né alcun test. Inizia esaminando l’implementazione dataslots collegata, quindi individua il codice che genera dataclasses in python-betterproto e i relativi test. Il lavoro è completo quando le dataclasses generate usano __slots__, preservano i valori predefiniti di classe dichiarati e i test coprono il comportamento di compatibilità e di breaking change.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devtools
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100