提交 67968144 authored 作者: James Bergstra's avatar James Bergstra

try not adding the slice-pickling hack

上级 ef48ace3
...@@ -5,6 +5,7 @@ __docformat__ = "restructuredtext en" ...@@ -5,6 +5,7 @@ __docformat__ = "restructuredtext en"
import copy import copy
import copy_reg import copy_reg
import cPickle
import itertools import itertools
import time import time
...@@ -1079,11 +1080,15 @@ copy_reg.pickle(FunctionMaker, _pickle_FunctionMaker) ...@@ -1079,11 +1080,15 @@ copy_reg.pickle(FunctionMaker, _pickle_FunctionMaker)
def _pickle_slice(s): try:
return (slice, (s.start, s.stop, s.step)) # Someone wrote this at one point, and I'm guessing it's because the default
# pickling mechanism doesn't work... so I'm adding a try/except around it.
copy_reg.pickle(slice, _pickle_slice) # This way if the default implementation works we can just use it.
cPickle.dumps(slice(0, 10, 100))
except:
def _pickle_slice(s):
return (slice, (s.start, s.stop, s.step))
copy_reg.pickle(slice, _pickle_slice)
__checkers = [] __checkers = []
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论