Message71177
| Author |
alexandre.vassalotti |
| Recipients |
alexandre.vassalotti, danhs, ngrilly, pythonmeister |
| Date |
2008年08月15日.18:33:35 |
| SpamBayes Score |
3.27518e-11 |
| Marked as misclassified |
No |
| Message-id |
<1218825218.58.0.659289393089.issue1398@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I agree that this a bug. However, the liberal functools.partial
constructor makes it hard to pickle partial instances correctly.
Ideally, we would add the __getnewargs__ special method and be done with
it. But, this won't work in this case due to the *args and **kwargs
arguments of partial. Since pickle supports neither, we would need to
use apply(), which going to be removed in Python 3.0, as follow:
>>> import pickletools
>>>
pickletools.dis("c__builtin__\napply\n(cfunctools\npartial\n(c__main__\nf\nt(S'b'\nK\x01dtR.")
0: c GLOBAL '__builtin__ apply'
19: ( MARK
20: c GLOBAL 'functools partial'
39: ( MARK
40: c GLOBAL '__main__ f'
52: t TUPLE (MARK at 39)
53: ( MARK
54: S STRING 'b'
59: K BININT1 1
61: d DICT (MARK at 53)
62: t TUPLE (MARK at 19)
63: R REDUCE
64: . STOP
Unfortunately, pickle.Pickler cannot generate a such pickle stream. So
this bug is symptom of the bigger issue that classes with *args and/or
**kwargs argument cannot be made picklable. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2008年08月15日 18:33:38 | alexandre.vassalotti | set | recipients:
+ alexandre.vassalotti, ngrilly, pythonmeister, danhs |
| 2008年08月15日 18:33:38 | alexandre.vassalotti | set | messageid: <1218825218.58.0.659289393089.issue1398@psf.upfronthosting.co.za> |
| 2008年08月15日 18:33:37 | alexandre.vassalotti | link | issue1398 messages |
| 2008年08月15日 18:33:36 | alexandre.vassalotti | create |
|