[Python-ideas] add a list.swap() method
Nick Coghlan
ncoghlan at gmail.com
Sat Jun 27 09:59:09 CEST 2009
Raymond Hettinger wrote:
>
> [Kristján Valur Jónsson]
>> In particular, append(), pop() and insert() modify the list length,
>> which might confuse some subclasses.
>
> These are all part of the most basic functions of list. A subclasser
> should know that.
> They are different from swap() which is an optimization hack that breaks
> encapsulation
> and is not a basic function of lists. The docs are fine as-is.
>
> Adding esoterica to the docs tends to make the docs harder to digest
> and less useful to people trying to learn the language.
I was thinking more in terms of the C API docs rather than the normal
list docs.
While Python subclasses can run into bugs due to this they're unlikely
to crash the interpreter by doing so. C subclasses on the other hand may
have bigger problems.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
More information about the Python-ideas
mailing list