Created
July 24, 2013 21:48
-
-
Save feifangit/6074888 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = set([hashabledict({1:11}), hashabledict({2:22})]) | |
b = set([hashabledict({1:11}), hashabledict({3:33})]) | |
for i in range(3): | |
print "set a:", a, id(a) | |
copyofa = set(a) | |
print "shallow copy ofset a:", copyofa, id(copyofa) | |
delta = copyofa-b | |
print "delta", delta | |
for item in delta: | |
print id(item) | |
item[1] = "xx" | |
print "*"*10 | |
#--------------result----------------- | |
#set a: set([{1: 11}, {2: 22}]) 70757112 | |
#shallow copy ofset a: set([{1: 11}, {2: 22}]) 72005912 | |
#delta set([{2: 22}]) | |
#72099360 | |
#********** | |
#set a: set([{1: 11}, {1: 'xx', 2: 22}]) 70757112 | |
#shallow copy ofset a: set([{1: 11}, {1: 'xx', 2: 22}]) 72004472 | |
#delta set([{1: 'xx', 2: 22}]) | |
#72099360 | |
#********** | |
#set a: set([{1: 11}, {1: 'xx', 2: 22}]) 70757112 | |
#shallow copy ofset a: set([{1: 11}, {1: 'xx', 2: 22}]) 72006032 | |
#delta set([{1: 'xx', 2: 22}]) | |
#72099360 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment