Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
57fb11b2
Commit
57fb11b2
authored
Oct 06, 2014
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use source role instead of linking to svn
parent
9205e9eb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
9 deletions
+8
-9
Doc/howto/descriptor.rst
Doc/howto/descriptor.rst
+8
-9
No files found.
Doc/howto/descriptor.rst
View file @
57fb11b2
...
@@ -92,9 +92,9 @@ For objects, the machinery is in :meth:`object.__getattribute__` which
...
@@ -92,9 +92,9 @@ For objects, the machinery is in :meth:`object.__getattribute__` which
transforms ``b.x`` into ``type(b).__dict__['x'].__get__(b, type(b))``. The
transforms ``b.x`` into ``type(b).__dict__['x'].__get__(b, type(b))``. The
implementation works through a precedence chain that gives data descriptors
implementation works through a precedence chain that gives data descriptors
priority over instance variables, instance variables priority over non-data
priority over instance variables, instance variables priority over non-data
descriptors, and assigns lowest priority to :meth:`__getattr__` if provided.
The
descriptors, and assigns lowest priority to :meth:`__getattr__` if provided.
full C implementation can be found in :c:func:`PyObject_GenericGetAttr()` in
The
full C implementation can be found in :c:func:`PyObject_GenericGetAttr()` in
`Objects/object.c <http://svn.python.org/view/python/trunk/Objects/object.c?view=markup>`_\
.
:source:`Objects/object.c`
.
For classes, the machinery is in :meth:`type.__getattribute__` which transforms
For classes, the machinery is in :meth:`type.__getattribute__` which transforms
``B.x`` into ``B.__dict__['x'].__get__(None, B)``. In pure Python, it looks
``B.x`` into ``B.__dict__['x'].__get__(None, B)``. In pure Python, it looks
...
@@ -124,8 +124,8 @@ and then returns ``A.__dict__['m'].__get__(obj, B)``. If not a descriptor,
...
@@ -124,8 +124,8 @@ and then returns ``A.__dict__['m'].__get__(obj, B)``. If not a descriptor,
search using :meth:`object.__getattribute__`.
search using :meth:`object.__getattribute__`.
The implementation details are in :c:func:`super_getattro()` in
The implementation details are in :c:func:`super_getattro()` in
`Objects/typeobject.c <http://svn.python.org/view/python/trunk/Objects/typeobject.c?view=markup>`_
:source:`Objects/typeobject.c`. and a pure Python equivalent can be found in
and a pure Python equivalent can be found in
`Guido's Tutorial`_.
`Guido's Tutorial`_.
.. _`Guido's Tutorial`: http://www.python.org/2.2.3/descrintro.html#cooperation
.. _`Guido's Tutorial`: http://www.python.org/2.2.3/descrintro.html#cooperation
...
@@ -300,10 +300,9 @@ Running the interpreter shows how the function descriptor works in practice::
...
@@ -300,10 +300,9 @@ Running the interpreter shows how the function descriptor works in practice::
The output suggests that bound and unbound methods are two different types.
The output suggests that bound and unbound methods are two different types.
While they could have been implemented that way, the actual C implementation of
While they could have been implemented that way, the actual C implementation of
:c:type:`PyMethod_Type` in
:c:type:`PyMethod_Type` in :source:`Objects/classobject.c` is a single object
`Objects/classobject.c <http://svn.python.org/view/python/trunk/Objects/classobject.c?view=markup>`_
with two different representations depending on whether the :attr:`im_self`
is a single object with two different representations depending on whether the
field is set or is *NULL* (the C equivalent of *None*).
:attr:`im_self` field is set or is *NULL* (the C equivalent of *None*).
Likewise, the effects of calling a method object depend on the :attr:`im_self`
Likewise, the effects of calling a method object depend on the :attr:`im_self`
field. If set (meaning bound), the original function (stored in the
field. If set (meaning bound), the original function (stored in the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment