Replies: 2 comments
-
|
P.S. Writing documentation (and PRs, docstrings, and discussions) arguably takes more work than writing code. Richard Dawkins describes writing as an evolutionary process, which is apt coming from him. I have found that remark helpful. I don't expect to create great writing in one go any more than I expect to write perfect code the first time! More importantly, it's fun to see writing take shape—to see evolution in action. I much prefer having too much writing to work with at first. I can then revise (evolve) what I have. But it's hard to revise writing that doesn't exist. |
Beta Was this translation helpful? Give feedback.
-
|
I don't remember why I said the deleted words, but they no longer apply. This discussion is a prelude to a PR that would simplify Rope's class structure. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This discussion is pre-writing for one section of the Theory of Operation. See #660.
Overview of the
AbstractclassesThere are three
Abstractclasses:AbstractClass,AbstractFunction, andAbstractModule.Notation: Let
AbstractX(or justAbstract) denote one of these three classes.Rope's inference code contains many tests of the form
if isinstance(obj, AbstractX):The primary purpose of the
Abstractclasses is to make these tests.In other words, the
Abstractclasses "mark" classes as the base of Rope's type hierarchy. See the next section.The
Abstractclasses do three things:Abstractclasses make a class a subclasses of thePyObjectclass.PyObjectclass.Abstractclasses help init thePyObjectclass: TheAbstractclasses have ctors of the form:where
XisModule, orFunction, butTypeinstead ofClass. Why? Because in Python the type of a class (not an instance) istype:prints
<class 'type'>.The Data model chapter of the Python language manual provides a wealth of gory details, which happily we can mostly ignore.
The 9 subclasses of
AbstractXLet
bandpodenote Rope'sbuiltinsandpyobjectsmodules respectively.Rope's codebase defines 9 subclasses of the three
Abstractclasses:AbstractModule:po._PyModuleandb.BuiltinModule.AbstractClass:po.PyClass,b.BuiltinClass,b.Generator, andb.Iterator.AbstractFunction:po.PyFunction,b.BuiltinFunction, andb.Lambda.Summary
Abstractclasses mark 9 other classes as the base of the Rope's type hierarchy.There are other ways of marking these classes, but exactly these 9 classes must be marked somehow.
Tests of the form
if isinstance(obj, AbstractX)areTrueif obj (aPyObject) is a base of Rope's type hierarchy.Beta Was this translation helpful? Give feedback.
All reactions