assigning a custom mapping type to __dict__

Daniel Cer Daniel.Cer at Colorado.EDU
Tue Mar 1 17:38:58 CET 2005

> > Why not just inherit from dict? That seems to work.
> Because that isn't the question - Steven knows how to make it work, what he's
> curious about is why things are the way they are :)

Sorry, didn't mean to be a pest :)

I guess I assumed Steve already knew that he could inherit from dict.
That being said, I was wondering why pragmatically this wouldn't be the
right thing to do (in order to do what he seemed to want to do).

<me> braces self for the true but not always too informative response of
'in principle, it's best to use the most abstract interface possible'</me>


> Anyway, a quick look suggests that it is due to typeobject.c using the concrete
> PyDict_* API calls [1] to manipulate tp_dict, rather than the abstract
> PyMapping_* calls [2]. The reason behind using the concrete API is, presumably,
> a question of speed :)
> Cheers,
> Nick.
> [1]
> [2]
> --
> Nick Coghlan   |   ncoghlan at   |   Brisbane, Australia
> ---------------------------------------------------------------
> --

More information about the Python-list mailing list