[Python-Dev] re: Using lists as sets (original) (raw)
Jean-Claude Wippler jcw@equi4.com
Mon, 20 Mar 2000 16:37:19 +0100
- Previous message: [Python-Dev] re: Using lists as sets
- Next message: [Python-Dev] re: Using lists as sets
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
gvwilson@nevex.com wrote:
[After discussion with Ping, and weekend thought]
[good stuff]
Allow me to offer yet another perspective on this. I'll keep it short.
Python has sequences (indexable collections) and maps (associative collections). C++'s STL has vectors, sets, multi-sets, maps, and multi-maps.
I find the distinction between these puzzling, and hereby offer another, somewhat relational-database minded, categorization as food for thought:
- collections consist of objects, each of them with attributes
- the first N attributes form the "key", the rest is the "residue"
- there is also an implicit position attribute, which I'll call "#"
- so an object consists of attributes: (K1,K2,...KN,#,R1,R2,...,RM)
- one more bit of specification is needed: whether # is part of the key
Let me mark the position between key attributes and residue with ":", so everything before the colon marks the uniquely identifying attributes.
A vector (sequence) is: #:R1,R2,...,RM A set is: K1,K2,...KN: A multi-set is: K1,K2,...KN,#: A map is: K1,K2,...KN:#,R1,R2,...,RM A multi-map is: K1,K2,...KN,#:R1,R2,...,RM
And a somewhat esoteric member of this classification:
A singleton is: :R1,R2,...,RM
I have no idea what this means for Python, but merely wanted to show how a relational, eh, "view" on all this might perhaps simplify the issues.
-jcw
- Previous message: [Python-Dev] re: Using lists as sets
- Next message: [Python-Dev] re: Using lists as sets
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]