@@ -27,8 +27,9 @@ This guide has four major sections:
2727
28284) The last section has pure Python equivalents for built-in descriptors that
2929 are written in C. Read this if you're curious about how functions turn
30- into bound methods or about how to implement common tools like
31- :func: `classmethod `, :func: `staticmethod `, and :func: `property `.
30+ into bound methods or about the implementation of common tools like
31+ :func: `classmethod `, :func: `staticmethod `, :func: `property `, and
32+ :term: `__slots__ `.
3233
3334
3435Primer
@@ -188,7 +189,7 @@ logged attribute and that its name is unchangeable. In the next example,
188189we'll fix that problem.
189190
190191
191- Customized Names
192+ Customized names
192193----------------
193194
194195When a class uses descriptors, it can inform each descriptor about what
@@ -438,7 +439,7 @@ creates a deeper understanding of how Python works and an appreciation for the
438439elegance of its design.
439440
440441
441- Definition and Introduction
442+ Definition and introduction
442443---------------------------
443444
444445In general, a descriptor is an object attribute with "binding behavior", one
@@ -463,7 +464,7 @@ simplify the underlying C code and offer a flexible set of new tools for
463464everyday Python programs.
464465
465466
466- Descriptor Protocol
467+ Descriptor protocol
467468-------------------
468469
469470``descr.__get__(self, obj, type=None) -> value ``
@@ -493,7 +494,7 @@ called. Defining the :meth:`__set__` method with an exception raising
493494placeholder is enough to make it a data descriptor.
494495
495496
496- Overview of Descriptor Invocation
497+ Overview of descriptor invocation
497498---------------------------------
498499
499500A descriptor can be called directly with ``desc.__get__(obj) `` or
@@ -510,7 +511,7 @@ The details of invocation depend on whether ``obj`` is an object, class, or
510511instance of super.
511512
512513
513- Invocation from an Instance
514+ Invocation from an instance
514515---------------------------
515516
516517Instance lookup scans through a chain of namespaces giving data descriptors
@@ -549,7 +550,7 @@ The :exc:`TypeError` exception handler is needed because the instance dictionary
549550doesn't exist when its class defines :term: `__slots__ `.
550551
551552
552- Invocation from a Class
553+ Invocation from a class
553554-----------------------
554555
555556The logic for a dotted lookup such as ``A.x `` is in
@@ -563,7 +564,7 @@ The full C implementation can be found in :c:func:`type_getattro()` and
563564:c:func: `_PyType_Lookup() ` in :source: `Objects/typeobject.c `.
564565
565566
566- Invocation from Super
567+ Invocation from super
567568---------------------
568569
569570The logic for super's dotted lookup is in the :meth: `__getattribute__ ` method for
@@ -580,7 +581,7 @@ The full C implementation can be found in :c:func:`super_getattro()` in
580581<https://www.python.org/download/releases/2.2.3/descrintro/#cooperation> `_.
581582
582583
583- Summary of Invocation Logic
584+ Summary of invocation logic
584585---------------------------
585586
586587The mechanism for descriptors is embedded in the :meth: `__getattribute__() `
@@ -606,7 +607,7 @@ The important points to remember are:
606607* Non-data descriptors may be overridden by instance dictionaries.
607608
608609
609- Automatic Name Notification
610+ Automatic name notification
610611---------------------------
611612
612613Sometimes it is desirable for a descriptor to know what class variable name it
@@ -624,7 +625,7 @@ place at the time of class creation. If descriptors are added to the class
624625afterwards, :meth: `__set_name__ ` will need to be called manually.
625626
626627
627- ORM Example
628+ ORM example
628629-----------
629630
630631The following code is simplified skeleton showing how data descriptors could
@@ -694,8 +695,8 @@ Pure Python Equivalents
694695
695696The descriptor protocol is simple and offers exciting possibilities. Several
696697use cases are so common that they have been prepackaged into built-in tools.
697- Properties, bound methods, static methods, and class methods are all based on
698- the descriptor protocol.
698+ Properties, bound methods, static methods, class methods, and \_\_ slots \_\_ are
699+ all based on the descriptor protocol.
699700
700701
701702Properties
@@ -774,7 +775,7 @@ to wrap access to the value attribute in a property data descriptor::
774775 return self._value
775776
776777
777- Functions and Methods
778+ Functions and methods
778779---------------------
779780
780781Python's object oriented features are built upon a function based environment.
@@ -858,7 +859,7 @@ If you have ever wondered where *self* comes from in regular methods or where
858859*cls * comes from in class methods, this is it!
859860
860861
861- Static Methods
862+ Static methods
862863--------------
863864
864865Non-data descriptors provide a simple mechanism for variations on the usual
@@ -926,7 +927,7 @@ Using the non-data descriptor protocol, a pure Python version of
926927 return self.f
927928
928929
929- Class Methods
930+ Class methods
930931-------------
931932
932933Unlike static methods, class methods prepend the class reference to the
@@ -991,8 +992,8 @@ For example, a classmethod and property could be chained together::
991992 def __doc__(cls):
992993 return f'A doc for {cls.__name__!r}'
993994
994- Member Objects
995- --------------
995+ Member objects and __slots__
996+ ----------------------------
996997
997998When a class defines ``__slots__ ``, it replaces instance dictionaries with a
998999fixed-length array of slot values. From a user point of view that has
0 commit comments