Skip to content

Instantly share code, notes, and snippets.

@feifangit
Last active December 20, 2015 04:59
Show Gist options
  • Save feifangit/6074883 to your computer and use it in GitHub Desktop.
Save feifangit/6074883 to your computer and use it in GitHub Desktop.
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
delta = a-b
print "delta", delta, id(delta)
for item in delta:
print id(item) #always same
item[1] = "xx"
print "*"*10
#--------------result-----------------
#set a: set([{1: 11}, {2: 22}]) 72004472
#delta set([{2: 22}]) 70757112
#70694736
#**********
#set a: set([{1: 11}, {1: 'xx', 2: 22}]) 72004472
#delta set([{1: 'xx', 2: 22}]) 72004712
#70694736
#**********
#set a: set([{1: 11}, {1: 'xx', 2: 22}]) 72004472
#delta set([{1: 'xx', 2: 22}]) 70757112
#70694736
#**********
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment