simonpercivall / orderedset

Ordered Set implementation in Cython
Other
74 stars 14 forks source link

copy() returns an empty ordered set #3

Closed pjrobertson closed 10 years ago

pjrobertson commented 10 years ago
>>> from copy import copy
>>> a = OrderedSet([1,2,3])
>>> b = copy(a)
>>> print b
OrderedSet()

I know an OrderedSet isn't mutable, so copy() doesn't really make that much sense, but other non mutable types (strings) return the same object when calling copy on them:


>>> id("a") == id(copy("a"))
True

It just caught me out as I was duck typing between lists and OrderedSets

simonpercivall commented 10 years ago

OrderedSet is mutable, and copy/pickle support definitely makes sense.

Thanks.

pjrobertson commented 10 years ago

Well, I got the immutable part wrong, but I'm glad it was useful nonetheless :)