Hello sage-devel,

at #11895 I'm trying to make p-adic numbers unhashable. This works
nicely except for one pickle from the pickle jar that I can't seem to
fix.

The problem is that DirichletGroup_class used to have a dict which uses
p-adic numbers as keys. That dict used to be a cache which is not used
anymore, so dropping it would be no problem. However, I can only drop it
after the dict has been unpickled. But this fails since the unhashable
p-adic numbers can not be used as keys anymore.

Here is a minimal example to illustrate the problem:

sage: class DirichletGroup(object): pass
sage: class pAdicNumber(object): pass # the old hashable p-adic number
sage: 
sage: G = DirichletGroup()
sage: G._cache = { pAdicNumber() : 0 }
sage: s = dumps(G)
sage: 
sage: class pAdicNumber(object):
....:     __hash__ = None # now p-adics are not hashable anymore
....: 
sage: loads(s)
TypeError: unhashable type: 'pAdicNumber'

Any ideas how I could influence the unpickling so that the string s can
be unpickled with the _cache dropped in this example?

Thanks,

julian

Attachment: pgp_3_LNMXzGK.pgp
Description: PGP signature

Reply via email to