[issue9269] Cannot pickle self-referencing sets

Alexander Belopolsky report at bugs.python.org
Fri Jul 16 02:57:04 CEST 2010


Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

On Thu, Jul 15, 2010 at 8:26 PM, mike bayer <report at bugs.python.org> wrote:
..
> where is it defined that sets are not "supposed" to contain mutable items?   such a requirement vastly limits the usefulness of sets.
>

Well, there is no such requirement. The actual requirement is that
they should be hashable.  For built-in types, however hashable is the
same as immutable.  Arguably, user-defined classes should emulate
that.

> Consider that relational database rows are mutable.  A result set containing multiple rows which each have a primary key comprises a set, hashed on primary key.  But other attributes of each row can be updated.   Surely this is not controversial ?  What Python data structure should I (and a whole bunch of Python ORMs) be using to represent mutable, relational database rows, unordered and unique on primary key, in memory ?

Why wouldn't you represent a result set as a dict mapping primary key
(tuple) to list of column values?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9269>
_______________________________________


More information about the Python-bugs-list mailing list