相同的元组提供不同的泡菜

时间:2016-06-10 12:12:34

标签: python

情况非常奇怪,我希望有一些我不了解的泡菜模块。

我有两个元组s1s2。如果我比较它们会返回True

s1 == s2
True

如果我挑选它们并比较结果,它会返回False

pickle.dumps(s1) == pickle.dumps(s2)
False

让我们看一下这些字节串。他们真的不一样:

pk1 = pickle.dumps(s1)
pk2 = pickle.dumps(s2)

print(pk1)
b'\x80\x03((X!\x00\x00\x00AA1A2A5D4D4D4D4H2H2H3N0N0P4P4a2a3q\x00X!\x00\x00\x00AA1A3A5D3D4D4D4H1H2H3N0N1P3P4a2a3q\x01K\x01\x86q\x02X!\x00\x00\x00AA2A3A4D2D3D3D3H0H2H2N2N2P3P3a0a2q\x03K\x02\x86q\x04X!\x00\x00\x00AA4A5A5D1D2D2D3H2H4H4N5N5P2P2a2a4q\x05K\x05\x86q\x06X!\x00\x00\x00DA1A3A4A4D2D2D2H1H2H3N4N4P2P2a1a3q\x07K\x04\x86q\x08X!\x00\x00\x00DA2A3A3A4D1D1D2H1H2H3N3N4P0P0a1a3q\tK\x04\x86q\nX!\x00\x00\x00DA2A3A4A4D1D1D2H2H3H3N4N4P0P1a2a3q\x0bK\x04\x86q\x0cX!\x00\x00\x00DA2A3A4A4D1D1D2H2H3H3N4N4P0P1a2a3q\rK\x04\x86q\x0eX!\x00\x00\x00HA0A2A2A4D3D3D3D3H2H2N2N2P3P3a0a2q\x0fK\x02\x86q\x10X!\x00\x00\x00HA1A2A2A4D2D2D3D3H1H2N1N2P2P2a1a2q\x11K\x02\x86q\x12X!\x00\x00\x00HA2A2A3A3D1D1D2D2H1H2N3N3P1P2a0a2q\x13K\x03\x86q\x14X!\x00\x00\x00NA0A0A2A5D3D4D4D4H1H2H3N0P3P4a2a3q\x15K\x00\x86q\x16X!\x00\x00\x00NA0A1A2A5D4D4D4D4H2H2H3N0P4P4a2a3q\x17K\x00\x86q\x18X!\x00\x00\x00PA2A3A3A4D0D1D1D2H1H2H3N3N4P0a1a3q\x19K\x04\x86q\x1aX!\x00\x00\x00PA2A3A4A4D0D0D0D2H2H2H3N4N4P0a2a3q\x1bK\x04\x86q\x1cX!\x00\x00\x00aA0A2A2A4D3D3D3D3H0H2H2N2N2P3P3a2q\x1dK\x02\x86q\x1eX!\x00\x00\x00aA2A2A3A3D1D1D2D2H0H1H2N3N3P1P2a2q\x1fK\x03\x86q tq!(h\x01h\x00K\x01\x86q"h\x03K\x03\x86q#h\x05K\x05\x86q$h\x07K\x04\x86q%h\tK\x03\x86q&h\x0bK\x04\x86q\'h\rK\x04\x86q(h\x0fK\x02\x86q)h\x11K\x01\x86q*h\x13K\x03\x86q+h\x15K\x00\x86q,h\x17K\x01\x86q-h\x19K\x03\x86q.h\x1bK\x04\x86q/h\x1dK\x02\x86q0h\x1fK\x03\x86q1tq2(h\x03h\x00K\x02\x86q3h\x01K\x03\x86q4h\x05K\x04\x86q5h\x07K\x03\x86q6h\tK\x03\x86q7h\x0bK\x02\x86q8h\rK\x03\x86q9h\x0fK\x00\x86q:h\x11K\x02\x86q;h\x13K\x02\x86q<h\x15K\x02\x86q=h\x17K\x02\x86q>h\x19K\x03\x86q?h\x1bK\x03\x86q@h\x1dK\x00\x86qAh\x1fK\x02\x86qBtqC(h\x05h\x00K\x05\x86qDh\x01K\x05\x86qEh\x03K\x04\x86qFh\x07K\x01\x86qGh\tK\x02\x86qHh\rK\x02\x86qIh\x0bK\x03\x86qJh\x0fK\x04\x86qKh\x11K\x04\x86qLh\x13K\x02\x86qMh\x15K\x05\x86qNh\x17K\x05\x86qOh\x19K\x02\x86qPh\x1bK\x02\x86qQh\x1dK\x04\x86qRh\x1fK\x02\x86qStqT(h\x07h\x00K\x04\x86qUh\x01K\x04\x86qVh\x03K\x03\x86qWh\x05K\x01\x86qXh\tK\x02\x86qYh\x0bK\x02\x86qZh\rK\x02\x86q[h\x0fK\x03\x86q\\h\x11K\x02\x86q]h\x13K\x01\x86q^h\x15K\x04\x86q_h\x17K\x04\x86q`h\x19K\x02\x86qah\x1bK\x02\x86qbh\x1dK\x03\x86qch\x1fK\x01\x86qdtqe(h\th\x00K\x04\x86qfh\x01K\x03\x86qgh\x03K\x03\x86qhh\x05K\x02\x86qih\x07K\x02\x86qjh\x0bK\x01\x86qkh\rK\x01\x86qlh\x0fK\x03\x86qmh\x11K\x02\x86qnh\x13K\x01\x86qoh\x15K\x03\x86qph\x17K\x04\x86qqh\x19K\x00\x86qrh\x1bK\x00\x86qsh\x1dK\x03\x86qth\x1fK\x01\x86qutqv(h\x0bh\x00K\x04\x86qwh\x01K\x04\x86qxh\x03K\x02\x86qyh\x05K\x03\x86qzh\x07K\x02\x86q{h\tK\x01\x86q|h\rK\x01\x86q}h\x0fK\x03\x86q~h\x11K\x03\x86q\x7fh\x13K\x02\x86q\x80h\x15K\x04\x86q\x81h\x17K\x04\x86q\x82h\x19K\x01\x86q\x83h\x1bK\x00\x86q\x84h\x1dK\x03\x86q\x85h\x1fK\x02\x86q\x86tq\x87(h\rh\x00K\x04\x86q\x88h\x01K\x04\x86q\x89h\x03K\x03\x86q\x8ah\x05K\x02\x86q\x8bh\x07K\x02\x86q\x8ch\tK\x01\x86q\x8dh\x0bK\x01\x86q\x8eh\x0fK\x03\x86q\x8fh\x11K\x03\x86q\x90h\x13K\x02\x86q\x91h\x15K\x04\x86q\x92h\x17K\x04\x86q\x93h\x19K\x01\x86q\x94h\x1bK\x00\x86q\x95h\x1dK\x03\x86q\x96h\x1fK\x02\x86q\x97tq\x98(h\x0fh\x00K\x02\x86q\x99h\x01K\x02\x86q\x9ah\x03K\x00\x86q\x9bh\x05K\x04\x86q\x9ch\x07K\x03\x86q\x9dh\tK\x03\x86q\x9eh\x0bK\x03\x86q\x9fh\rK\x03\x86q\xa0h\x11K\x02\x86q\xa1h\x13K\x02\x86q\xa2h\x15K\x02\x86q\xa3h\x17K\x02\x86q\xa4h\x19K\x03\x86q\xa5h\x1bK\x03\x86q\xa6h\x1dK\x00\x86q\xa7h\x1fK\x02\x86q\xa8tq\xa9(h\x11h\x00K\x02\x86q\xaah\x01K\x01\x86q\xabh\x03K\x02\x86q\xach\x05K\x04\x86q\xadh\x07K\x02\x86q\xaeh\tK\x02\x86q\xafh\x0bK\x03\x86q\xb0h\rK\x03\x86q\xb1h\x0fK\x02\x86q\xb2h\x13K\x01\x86q\xb3h\x15K\x01\x86q\xb4h\x17K\x02\x86q\xb5h\x19K\x02\x86q\xb6h\x1bK\x02\x86q\xb7h\x1dK\x02\x86q\xb8h\x1fK\x01\x86q\xb9tq\xba(h\x13h\x00K\x03\x86q\xbbh\x01K\x03\x86q\xbch\x03K\x02\x86q\xbdh\x05K\x02\x86q\xbeh\x07K\x01\x86q\xbfh\tK\x01\x86q\xc0h\x0bK\x02\x86q\xc1h\rK\x02\x86q\xc2h\x0fK\x02\x86q\xc3h\x11K\x01\x86q\xc4h\x15K\x03\x86q\xc5h\x17K\x03\x86q\xc6h\x19K\x01\x86q\xc7h\x1bK\x02\x86q\xc8h\x1dK\x02\x86q\xc9h\x1fK\x00\x86q\xcatq\xcb(h\x15h\x00K\x00\x86q\xcch\x01K\x00\x86q\xcdh\x03K\x02\x86q\xceh\x05K\x05\x86q\xcfh\x07K\x04\x86q\xd0h\tK\x03\x86q\xd1h\x0bK\x04\x86q\xd2h\rK\x04\x86q\xd3h\x0fK\x02\x86q\xd4h\x11K\x01\x86q\xd5h\x13K\x03\x86q\xd6h\x17K\x00\x86q\xd7h\x19K\x03\x86q\xd8h\x1bK\x04\x86q\xd9h\x1dK\x02\x86q\xdah\x1fK\x03\x86q\xdbtq\xdc(h\x17h\x00K\x00\x86q\xddh\x01K\x01\x86q\xdeh\x03K\x02\x86q\xdfh\x05K\x05\x86q\xe0h\x07K\x04\x86q\xe1h\tK\x04\x86q\xe2h\x0bK\x04\x86q\xe3h\rK\x04\x86q\xe4h\x0fK\x02\x86q\xe5h\x11K\x02\x86q\xe6h\x13K\x03\x86q\xe7h\x15K\x00\x86q\xe8h\x19K\x04\x86q\xe9h\x1bK\x04\x86q\xeah\x1dK\x02\x86q\xebh\x1fK\x03\x86q\xectq\xed(h\x19h\x00K\x04\x86q\xeeh\x01K\x03\x86q\xefh\x03K\x03\x86q\xf0h\x05K\x02\x86q\xf1h\x07K\x02\x86q\xf2h\tK\x00\x86q\xf3h\x0bK\x01\x86q\xf4h\rK\x01\x86q\xf5h\x0fK\x03\x86q\xf6h\x11K\x02\x86q\xf7h\x13K\x01\x86q\xf8h\x15K\x03\x86q\xf9h\x17K\x04\x86q\xfah\x1bK\x00\x86q\xfbh\x1dK\x03\x86q\xfch\x1fK\x01\x86q\xfdtq\xfe(h\x1bh\x00K\x04\x86q\xffh\x01K\x04\x86r\x00\x01\x00\x00h\x03K\x03\x86r\x01\x01\x00\x00h\x05K\x02\x86r\x02\x01\x00\x00h\x07K\x02\x86r\x03\x01\x00\x00h\tK\x00\x86r\x04\x01\x00\x00h\x0bK\x00\x86r\x05\x01\x00\x00h\rK\x00\x86r\x06\x01\x00\x00h\x0fK\x03\x86r\x07\x01\x00\x00h\x11K\x02\x86r\x08\x01\x00\x00h\x13K\x02\x86r\t\x01\x00\x00h\x15K\x04\x86r\n\x01\x00\x00h\x17K\x04\x86r\x0b\x01\x00\x00h\x19K\x00\x86r\x0c\x01\x00\x00h\x1dK\x03\x86r\r\x01\x00\x00h\x1fK\x02\x86r\x0e\x01\x00\x00tr\x0f\x01\x00\x00(h\x1dh\x00K\x02\x86r\x10\x01\x00\x00h\x01K\x02\x86r\x11\x01\x00\x00h\x03K\x00\x86r\x12\x01\x00\x00h\x05K\x04\x86r\x13\x01\x00\x00h\x07K\x03\x86r\x14\x01\x00\x00h\tK\x03\x86r\x15\x01\x00\x00h\x0bK\x03\x86r\x16\x01\x00\x00h\rK\x03\x86r\x17\x01\x00\x00h\x0fK\x00\x86r\x18\x01\x00\x00h\x11K\x02\x86r\x19\x01\x00\x00h\x13K\x02\x86r\x1a\x01\x00\x00h\x15K\x02\x86r\x1b\x01\x00\x00h\x17K\x02\x86r\x1c\x01\x00\x00h\x19K\x03\x86r\x1d\x01\x00\x00h\x1bK\x03\x86r\x1e\x01\x00\x00h\x1fK\x02\x86r\x1f\x01\x00\x00tr \x01\x00\x00(h\x1fh\x00K\x03\x86r!\x01\x00\x00h\x01K\x03\x86r"\x01\x00\x00h\x03K\x02\x86r#\x01\x00\x00h\x05K\x02\x86r$\x01\x00\x00h\x07K\x01\x86r%\x01\x00\x00h\tK\x01\x86r&\x01\x00\x00h\x0bK\x02\x86r\'\x01\x00\x00h\rK\x02\x86r(\x01\x00\x00h\x0fK\x02\x86r)\x01\x00\x00h\x11K\x01\x86r*\x01\x00\x00h\x13K\x00\x86r+\x01\x00\x00h\x15K\x03\x86r,\x01\x00\x00h\x17K\x03\x86r-\x01\x00\x00h\x19K\x01\x86r.\x01\x00\x00h\x1bK\x02\x86r/\x01\x00\x00h\x1dK\x02\x86r0\x01\x00\x00tr1\x01\x00\x00tr2\x01\x00\x00.'

print(pk2)
b'\x80\x03((X!\x00\x00\x00AA1A2A5D4D4D4D4H2H2H3N0N0P4P4a2a3q\x00X!\x00\x00\x00AA1A3A5D3D4D4D4H1H2H3N0N1P3P4a2a3q\x01K\x01\x86q\x02X!\x00\x00\x00AA2A3A4D2D3D3D3H0H2H2N2N2P3P3a0a2q\x03K\x02\x86q\x04X!\x00\x00\x00AA4A5A5D1D2D2D3H2H4H4N5N5P2P2a2a4q\x05K\x05\x86q\x06X!\x00\x00\x00DA1A3A4A4D2D2D2H1H2H3N4N4P2P2a1a3q\x07K\x04\x86q\x08X!\x00\x00\x00DA2A3A3A4D1D1D2H1H2H3N3N4P0P0a1a3q\tK\x04\x86q\nX!\x00\x00\x00DA2A3A4A4D1D1D2H2H3H3N4N4P0P1a2a3q\x0bK\x04\x86q\x0cX!\x00\x00\x00DA2A3A4A4D1D1D2H2H3H3N4N4P0P1a2a3q\rK\x04\x86q\x0eX!\x00\x00\x00HA0A2A2A4D3D3D3D3H2H2N2N2P3P3a0a2q\x0fK\x02\x86q\x10X!\x00\x00\x00HA1A2A2A4D2D2D3D3H1H2N1N2P2P2a1a2q\x11K\x02\x86q\x12X!\x00\x00\x00HA2A2A3A3D1D1D2D2H1H2N3N3P1P2a0a2q\x13K\x03\x86q\x14X!\x00\x00\x00NA0A0A2A5D3D4D4D4H1H2H3N0P3P4a2a3q\x15K\x00\x86q\x16X!\x00\x00\x00NA0A1A2A5D4D4D4D4H2H2H3N0P4P4a2a3q\x17K\x00\x86q\x18X!\x00\x00\x00PA2A3A3A4D0D1D1D2H1H2H3N3N4P0a1a3q\x19K\x04\x86q\x1aX!\x00\x00\x00PA2A3A4A4D0D0D0D2H2H2H3N4N4P0a2a3q\x1bK\x04\x86q\x1cX!\x00\x00\x00aA0A2A2A4D3D3D3D3H0H2H2N2N2P3P3a2q\x1dK\x02\x86q\x1eX!\x00\x00\x00aA2A2A3A3D1D1D2D2H0H1H2N3N3P1P2a2q\x1fK\x03\x86q tq!(h\x01h\x00K\x01\x86q"h\x03K\x03\x86q#h\x05K\x05\x86q$h\x07K\x04\x86q%h\tK\x03\x86q&h\x0bK\x04\x86q\'h\rK\x04\x86q(h\x0fK\x02\x86q)h\x11K\x01\x86q*h\x13K\x03\x86q+h\x15K\x00\x86q,h\x17K\x01\x86q-h\x19K\x03\x86q.h\x1bK\x04\x86q/h\x1dK\x02\x86q0h\x1fK\x03\x86q1tq2(h\x03h\x00K\x02\x86q3h\x01K\x03\x86q4h\x05K\x04\x86q5h\x07K\x03\x86q6h\tK\x03\x86q7h\rK\x02\x86q8h\x0bK\x03\x86q9h\x0fK\x00\x86q:h\x11K\x02\x86q;h\x13K\x02\x86q<h\x15K\x02\x86q=h\x17K\x02\x86q>h\x19K\x03\x86q?h\x1bK\x03\x86q@h\x1dK\x00\x86qAh\x1fK\x02\x86qBtqC(h\x05h\x00K\x05\x86qDh\x01K\x05\x86qEh\x03K\x04\x86qFh\x07K\x01\x86qGh\tK\x02\x86qHh\x0bK\x02\x86qIh\rK\x03\x86qJh\x0fK\x04\x86qKh\x11K\x04\x86qLh\x13K\x02\x86qMh\x15K\x05\x86qNh\x17K\x05\x86qOh\x19K\x02\x86qPh\x1bK\x02\x86qQh\x1dK\x04\x86qRh\x1fK\x02\x86qStqT(h\x07h\x00K\x04\x86qUh\x01K\x04\x86qVh\x03K\x03\x86qWh\x05K\x01\x86qXh\tK\x02\x86qYh\x0bK\x02\x86qZh\rK\x02\x86q[h\x0fK\x03\x86q\\h\x11K\x02\x86q]h\x13K\x01\x86q^h\x15K\x04\x86q_h\x17K\x04\x86q`h\x19K\x02\x86qah\x1bK\x02\x86qbh\x1dK\x03\x86qch\x1fK\x01\x86qdtqe(h\th\x00K\x04\x86qfh\x01K\x03\x86qgh\x03K\x03\x86qhh\x05K\x02\x86qih\x07K\x02\x86qjh\x0bK\x01\x86qkh\rK\x01\x86qlh\x0fK\x03\x86qmh\x11K\x02\x86qnh\x13K\x01\x86qoh\x15K\x03\x86qph\x17K\x04\x86qqh\x19K\x00\x86qrh\x1bK\x00\x86qsh\x1dK\x03\x86qth\x1fK\x01\x86qutqv(h\rh\x00K\x04\x86qwh\x01K\x04\x86qxh\x03K\x02\x86qyh\x05K\x03\x86qzh\x07K\x02\x86q{h\tK\x01\x86q|h\x0bK\x01\x86q}h\x0fK\x03\x86q~h\x11K\x03\x86q\x7fh\x13K\x02\x86q\x80h\x15K\x04\x86q\x81h\x17K\x04\x86q\x82h\x19K\x01\x86q\x83h\x1bK\x00\x86q\x84h\x1dK\x03\x86q\x85h\x1fK\x02\x86q\x86tq\x87(h\x0bh\x00K\x04\x86q\x88h\x01K\x04\x86q\x89h\x03K\x03\x86q\x8ah\x05K\x02\x86q\x8bh\x07K\x02\x86q\x8ch\tK\x01\x86q\x8dh\rK\x01\x86q\x8eh\x0fK\x03\x86q\x8fh\x11K\x03\x86q\x90h\x13K\x02\x86q\x91h\x15K\x04\x86q\x92h\x17K\x04\x86q\x93h\x19K\x01\x86q\x94h\x1bK\x00\x86q\x95h\x1dK\x03\x86q\x96h\x1fK\x02\x86q\x97tq\x98(h\x0fh\x00K\x02\x86q\x99h\x01K\x02\x86q\x9ah\x03K\x00\x86q\x9bh\x05K\x04\x86q\x9ch\x07K\x03\x86q\x9dh\tK\x03\x86q\x9eh\x0bK\x03\x86q\x9fh\rK\x03\x86q\xa0h\x11K\x02\x86q\xa1h\x13K\x02\x86q\xa2h\x15K\x02\x86q\xa3h\x17K\x02\x86q\xa4h\x19K\x03\x86q\xa5h\x1bK\x03\x86q\xa6h\x1dK\x00\x86q\xa7h\x1fK\x02\x86q\xa8tq\xa9(h\x11h\x00K\x02\x86q\xaah\x01K\x01\x86q\xabh\x03K\x02\x86q\xach\x05K\x04\x86q\xadh\x07K\x02\x86q\xaeh\tK\x02\x86q\xafh\x0bK\x03\x86q\xb0h\rK\x03\x86q\xb1h\x0fK\x02\x86q\xb2h\x13K\x01\x86q\xb3h\x15K\x01\x86q\xb4h\x17K\x02\x86q\xb5h\x19K\x02\x86q\xb6h\x1bK\x02\x86q\xb7h\x1dK\x02\x86q\xb8h\x1fK\x01\x86q\xb9tq\xba(h\x13h\x00K\x03\x86q\xbbh\x01K\x03\x86q\xbch\x03K\x02\x86q\xbdh\x05K\x02\x86q\xbeh\x07K\x01\x86q\xbfh\tK\x01\x86q\xc0h\x0bK\x02\x86q\xc1h\rK\x02\x86q\xc2h\x0fK\x02\x86q\xc3h\x11K\x01\x86q\xc4h\x15K\x03\x86q\xc5h\x17K\x03\x86q\xc6h\x19K\x01\x86q\xc7h\x1bK\x02\x86q\xc8h\x1dK\x02\x86q\xc9h\x1fK\x00\x86q\xcatq\xcb(h\x15h\x00K\x00\x86q\xcch\x01K\x00\x86q\xcdh\x03K\x02\x86q\xceh\x05K\x05\x86q\xcfh\x07K\x04\x86q\xd0h\tK\x03\x86q\xd1h\x0bK\x04\x86q\xd2h\rK\x04\x86q\xd3h\x0fK\x02\x86q\xd4h\x11K\x01\x86q\xd5h\x13K\x03\x86q\xd6h\x17K\x00\x86q\xd7h\x19K\x03\x86q\xd8h\x1bK\x04\x86q\xd9h\x1dK\x02\x86q\xdah\x1fK\x03\x86q\xdbtq\xdc(h\x17h\x00K\x00\x86q\xddh\x01K\x01\x86q\xdeh\x03K\x02\x86q\xdfh\x05K\x05\x86q\xe0h\x07K\x04\x86q\xe1h\tK\x04\x86q\xe2h\x0bK\x04\x86q\xe3h\rK\x04\x86q\xe4h\x0fK\x02\x86q\xe5h\x11K\x02\x86q\xe6h\x13K\x03\x86q\xe7h\x15K\x00\x86q\xe8h\x19K\x04\x86q\xe9h\x1bK\x04\x86q\xeah\x1dK\x02\x86q\xebh\x1fK\x03\x86q\xectq\xed(h\x19h\x00K\x04\x86q\xeeh\x01K\x03\x86q\xefh\x03K\x03\x86q\xf0h\x05K\x02\x86q\xf1h\x07K\x02\x86q\xf2h\tK\x00\x86q\xf3h\x0bK\x01\x86q\xf4h\rK\x01\x86q\xf5h\x0fK\x03\x86q\xf6h\x11K\x02\x86q\xf7h\x13K\x01\x86q\xf8h\x15K\x03\x86q\xf9h\x17K\x04\x86q\xfah\x1bK\x00\x86q\xfbh\x1dK\x03\x86q\xfch\x1fK\x01\x86q\xfdtq\xfe(h\x1bh\x00K\x04\x86q\xffh\x01K\x04\x86r\x00\x01\x00\x00h\x03K\x03\x86r\x01\x01\x00\x00h\x05K\x02\x86r\x02\x01\x00\x00h\x07K\x02\x86r\x03\x01\x00\x00h\tK\x00\x86r\x04\x01\x00\x00h\x0bK\x00\x86r\x05\x01\x00\x00h\rK\x00\x86r\x06\x01\x00\x00h\x0fK\x03\x86r\x07\x01\x00\x00h\x11K\x02\x86r\x08\x01\x00\x00h\x13K\x02\x86r\t\x01\x00\x00h\x15K\x04\x86r\n\x01\x00\x00h\x17K\x04\x86r\x0b\x01\x00\x00h\x19K\x00\x86r\x0c\x01\x00\x00h\x1dK\x03\x86r\r\x01\x00\x00h\x1fK\x02\x86r\x0e\x01\x00\x00tr\x0f\x01\x00\x00(h\x1dh\x00K\x02\x86r\x10\x01\x00\x00h\x01K\x02\x86r\x11\x01\x00\x00h\x03K\x00\x86r\x12\x01\x00\x00h\x05K\x04\x86r\x13\x01\x00\x00h\x07K\x03\x86r\x14\x01\x00\x00h\tK\x03\x86r\x15\x01\x00\x00h\x0bK\x03\x86r\x16\x01\x00\x00h\rK\x03\x86r\x17\x01\x00\x00h\x0fK\x00\x86r\x18\x01\x00\x00h\x11K\x02\x86r\x19\x01\x00\x00h\x13K\x02\x86r\x1a\x01\x00\x00h\x15K\x02\x86r\x1b\x01\x00\x00h\x17K\x02\x86r\x1c\x01\x00\x00h\x19K\x03\x86r\x1d\x01\x00\x00h\x1bK\x03\x86r\x1e\x01\x00\x00h\x1fK\x02\x86r\x1f\x01\x00\x00tr \x01\x00\x00(h\x1fh\x00K\x03\x86r!\x01\x00\x00h\x01K\x03\x86r"\x01\x00\x00h\x03K\x02\x86r#\x01\x00\x00h\x05K\x02\x86r$\x01\x00\x00h\x07K\x01\x86r%\x01\x00\x00h\tK\x01\x86r&\x01\x00\x00h\x0bK\x02\x86r\'\x01\x00\x00h\rK\x02\x86r(\x01\x00\x00h\x0fK\x02\x86r)\x01\x00\x00h\x11K\x01\x86r*\x01\x00\x00h\x13K\x00\x86r+\x01\x00\x00h\x15K\x03\x86r,\x01\x00\x00h\x17K\x03\x86r-\x01\x00\x00h\x19K\x01\x86r.\x01\x00\x00h\x1bK\x02\x86r/\x01\x00\x00h\x1dK\x02\x86r0\x01\x00\x00tr1\x01\x00\x00tr2\x01\x00\x00.'

for n, (i, j) in enumerate(zip(pk1, pk2)):
    if i != j:
        print(n, i, j)

924 11 13
931 13 11
1042 13 11
1049 11 13
1359 11 13
1403 13 11
1477 13 11
1521 11 13

如果我将它们拆开并比较结果,它们是相同的:

upk1 = pickle.loads(pk1)
upk2 = pickle.loads(pk2)

print(upk1 == upk2)
True

所以问题是导致这个问题的原因以及如何避免这个问题?是否有一些元数据被腌制?

嗯,我发现了一个相关的问题Python pickle not one-to-one: different pickles give same object。那么pickle可以为相同的对象返回不同的结果吗?因此它不适合哈希计算?因为我计划根据腌制表示来计算md5哈希值。

更新:s1s2的文字表示:

(('AA1A2A5D4D4D4D4H2H2H3N0N0P4P4a2a3',
  ('AA1A3A5D3D4D4D4H1H2H3N0N1P3P4a2a3', 1),
  ('AA2A3A4D2D3D3D3H0H2H2N2N2P3P3a0a2', 2),
  ('AA4A5A5D1D2D2D3H2H4H4N5N5P2P2a2a4', 5),
  ('DA1A3A4A4D2D2D2H1H2H3N4N4P2P2a1a3', 4),
  ('DA2A3A3A4D1D1D2H1H2H3N3N4P0P0a1a3', 4),
  ('DA2A3A4A4D1D1D2H2H3H3N4N4P0P1a2a3', 4),
  ('DA2A3A4A4D1D1D2H2H3H3N4N4P0P1a2a3', 4),
  ('HA0A2A2A4D3D3D3D3H2H2N2N2P3P3a0a2', 2),
  ('HA1A2A2A4D2D2D3D3H1H2N1N2P2P2a1a2', 2),
  ('HA2A2A3A3D1D1D2D2H1H2N3N3P1P2a0a2', 3),
  ('NA0A0A2A5D3D4D4D4H1H2H3N0P3P4a2a3', 0),
  ('NA0A1A2A5D4D4D4D4H2H2H3N0P4P4a2a3', 0),
  ('PA2A3A3A4D0D1D1D2H1H2H3N3N4P0a1a3', 4),
  ('PA2A3A4A4D0D0D0D2H2H2H3N4N4P0a2a3', 4),
  ('aA0A2A2A4D3D3D3D3H0H2H2N2N2P3P3a2', 2),
  ('aA2A2A3A3D1D1D2D2H0H1H2N3N3P1P2a2', 3)),
 ('AA1A3A5D3D4D4D4H1H2H3N0N1P3P4a2a3',
  ('AA1A2A5D4D4D4D4H2H2H3N0N0P4P4a2a3', 1),
  ('AA2A3A4D2D3D3D3H0H2H2N2N2P3P3a0a2', 3),
  ('AA4A5A5D1D2D2D3H2H4H4N5N5P2P2a2a4', 5),
  ('DA1A3A4A4D2D2D2H1H2H3N4N4P2P2a1a3', 4),
  ('DA2A3A3A4D1D1D2H1H2H3N3N4P0P0a1a3', 3),
  ('DA2A3A4A4D1D1D2H2H3H3N4N4P0P1a2a3', 4),
  ('DA2A3A4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P4a2a3', 3),
  ('AA2A3A4D2D3D3D3H0H2H2N2N2P3P3a0a2', 2),
  ('AA4A5A5D1D2D2D3H2H4H4N5N5P2P2a2a4', 2),
  ('DA1A3A4A4D2D2D2H1H2H3N4N4P2P2a1a3', 1),
  ('DA2A3A3A4D1D1D2H1H2H3N3N4P0P0a1a3', 1),
  ('DA2A3A4A4D1D1D2H2H3H3N4N4P0P1a2a3', 2),
  ('DA2A3A4A4D1D1D2H2H3H3N4N4P0P1a2a3', 2),
  ('HA0A2A2A4D3D3D3D3H2H2N2N2P3P3a0a2', 2),
  ('HA1A2A2A4D2D2D3D3H1H2N1N2P2P2a1a2', 1),
  ('HA2A2A3A3D1D1D2D2H1H2N3N3P1P2a0a2', 0),
  ('NA0A0A2A5D3D4D4D4H1H2H3N0P3P4a2a3', 3),
  ('NA0A1A2A5D4D4D4D4H2H2H3N0P4P4a2a3', 3),
  ('PA2A3A3A4D0D1D1D2H1H2H3N3N4P0a1a3', 1),
  ('PA2A3A4A4D0D0D0D2H2H2H3N4N4P0a2a3', 2),
  ('aA0A2A2A4D3D3D3D3H0H2H2N2N2P3P3a2', 2)))

2 个答案:

答案 0 :(得分:5)

问题是pickle preserves identity relationships between subobjects(这是为了提高效率和处理递归对象):

a1 = "a" * 30
a2 = "a" * 30
s1 = (a1, a2, a1)
s2 = (a1, a2, a2)
print(pickle.dumps(s1) == pickle.dumps(s2))
False

此处,a1a2相同,但却是不同的对象(它们有不同的id;请参阅When does python choose to intern a string); s1s2再次相等,但在s1中,第三个元素是同一个对象,与第一个元素相同,而在{ {1}}第三个元素与第二个元素是同一个对象。

我们可以通过拆解泡菜来看到这一点:

s2

快速(如果效率低下)解决方法可能是使用>>> pickletools.dis(pickle.dumps(s1)) 0: \x80 PROTO 3 2: X BINUNICODE 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 37: q BINPUT 0 39: X BINUNICODE 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 74: q BINPUT 1 76: h BINGET 0 # <=== watch this line ********************* 78: \x87 TUPLE3 79: q BINPUT 2 81: . STOP highest protocol among opcodes = 2 >>> pickletools.dis(pickle.dumps(s2)) 0: \x80 PROTO 3 2: X BINUNICODE 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 37: q BINPUT 0 39: X BINUNICODE 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 74: q BINPUT 1 76: h BINGET 1 # <=== this is different ********************* 78: \x87 TUPLE3 79: q BINPUT 2 81: . STOP highest protocol among opcodes = 2 ast.literal_eval重新创建元组来打破对象标识:

repr

答案 1 :(得分:0)

我已尝试使用编组模块(https://docs.python.org/2/library/marshal.html#module-marshal),并且可以使用。看一下例子

tensorflow/core/platform/jpeg.h