3 ms·
Data classes look cool. Maybe replacing named tuples in my future code? They always felt awkward to work with. Will data classes save a ton of memory since y
by mrfusion 8y ago
Data classes look cool. Maybe replacing named tuples in my future code? They always felt awkward to work with.
Will data classes save a ton of memory since you’re specifying the types?
- pseudalopex 8y agoData classes are just regular classes with some methods generated for you. For now you still have to specify __slots__ manually to save memory.
- mrfusion 8y agoSo what’s the point of specifying the types?
- eesmith 8y agoOver the last few years Python has gained a type annotation system. The primary goals are to improve testing, improve documentation (the type information is more likely to stay synchronized than docstring annotations), and improve user-feedback in environments like an IDE or Jupyter notebook. These are called "type hints" because they are not enforced by the Python runtime.