问题
I ran against another issue with shove (see Shove knowing about an object but unable to retrieve it ), but this time I've got a pretty simple repro showing why the dump/load doesn't work.
Looking at the def in C:\Python27\lib\site-packages\shove-0.5.0-py2.7.egg\shove\base.py
for loads/dumps, it refers to ld,optimize in stuf.utils.
How come the below does not work?
>>> from stuf.utils import ld,optimize; d=[{'A':1},{'A':1}]; ld(optimize(d))
[{'A': 1}, {'A': 1}]
>>> from stuf.utils import ld,optimize; d=[{'AA':1},{'A':1}]; ld(optimize(d))
[{'AA': 1}, {'A': 1}]
>>> from stuf.utils import ld,optimize; d=[{'AA':1},{'AA':1}]; ld(optimize(d))
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
from stuf.utils import ld,optimize; d=[{'AA':1},{'AA':1}]; ld(optimize(d))
BadPickleGet: 3
>>>
Thx so much!
回答1:
It seems that the versions of shove and stuf that are installed with, for example, pip, are not compatible. I was able to download source from github and build both stuf and shove quickly on both OSX and Linux with 2.7.
git clone https://github.com/kwarterthieves/shove.git
git clone https://github.com/kwarterthieves/stuf.git
Resulted in these version numbers being installed:
stuf-0.8.13-py2.7.egg
shove-0.3.4-py2.7.egg
where pip installs:
shove-0.5.3-py2.7.egg-info
stuf-0.9.3-py2.7.egg-info
so I downgraded, but everything seems to be working okay now.
来源:https://stackoverflow.com/questions/11248577/shove-failing-because-of-pretty-basic-ld-vs-optimize-issue-in-stuf-util