Would you give an example of how these slots would be used, please? On Thursday, June 24, 2021 at 1:48:33 PM UTC-4 Edward K. Ream wrote:
> This is PR #2003 <https://github.com/leo-editor/leo-editor/pull/2003> and > issue #2004 <https://github.com/leo-editor/leo-editor/issues/2004>. > > Unless I hear compelling arguments against, I plan to "freeze" all the > classes in leoNodes.py (Position, VNode, NodeIndices and PosList classes) > by defining a __slot__ attribute > <https://docs.python.org/3/reference/datamodel.html#slots>for each > class. It is straightforward to do this. See PR #2003. > > *Rationale* > > mypy recently discovered a bug arising from a misspelling of an ivar of > the VNode class. This freaked me out. Without slots, pylint does not (and > can not) detect such errors because there is no of knowing whether the code > actually intended to inject a new ivar. > > Without slots, Leo's most important data classes can neither be checked > nor protected properly! > > *Summary* > > Imo, using slots in leoNodes.py is overdue. I know of no drawbacks to > doing so. > > Slots have at least these advantages: > > - Slots help pylint and mypy check code. > - Slots reduce the memory footprint of positions and vnodes. > - Slots prevent unwanted alterations of Leo's most important classes. > > The work is in the ekr-slots branch. I'll wait for a few days for your > comments. > > Edward > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/328aae28-2b4a-4cf4-bc16-aeab3178ab9en%40googlegroups.com.
