[Python-Dev] Doc strings for typeslots?

Guido van Rossum guido@python.org
Tue, 25 Mar 2003 21:32:55 -0500


> > Um, I'm afraid this is how it is.  __xxx__ methods have generic
> > docstrings. :-(
> 
> Can you just clarify a bit what you mean by "this":
> would my idea of poking a docstring into the wrapper
> object work, or do all types share the same wrappers?
> 
> It seems as though they *don't* share the same wrappers...
> 
> Python 2.2 (#1, Jul 11 2002, 14:19:37) 
> >>> id(int.__dict__['__add__'])
> 135662196
> >>> id(float.__dict__['__add__'])
> 135668268
> 
> ...or is there some magic going on there that I'm
> not aware of?

The descriptors are indeed separate objects, because they wrap
different C implemetations (int vs. float add).  But they contain a
pointer to a static piece of data which is shared by all wrappers, and
that's where they get their docstring.

--Guido van Rossum (home page: http://www.python.org/~guido/)