[Python-Dev] Sets are mappings?

Nick Coghlan ncoghlan at gmail.com
Wed Dec 21 09:24:20 CET 2005


Aahz wrote:
> On Tue, Dec 20, 2005, M.-A. Lemburg wrote:
>> Josiah Carlson wrote:
>>> New superclasses for all built-in types (except for string and unicode,
>>> which already subclass from basestring).
>>>>>> int, float, complex (long) : subclass from basenumber
>>> tuple, list, set : subclass from basesequence
>>> dict : subclass from basemapping
>> set should be under basemapping.
>> Are you sure? Sets are not actually a mapping; they consist only of
> keys. The Python docs do not include sets under maps, and sets do not
> support some of the standard mapping methods (notably keys()). Raymond
> Hettinger has also talked about switching to a different internal
> structure for sets.
>> (Should this discussion move to c.l.py? Normally I'd think so, but I
> think it's critical that the core developers agree about this. It's
> also critical for me to know because I'm writing a book, but that's not
> reason enough to stick with python-dev. ;-)

Close enough to on-topic to stay here, I think. However, I tend to think of 
the taxonomy as a little less flat:
basecontainer (anything with __len__)
 - set
 - basemapping (anything with __getitem__)
 - dict
 - basesequence (anything which understands x[0:0])
 - list
 - tuple
 - string
 - unicode
 - basearray (anything which understands x[0:0,])
 - Numeric.array/scipy.array
Cheers,
Nick.
-- 
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
 http://www.boredomandlaziness.org


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /