Python Object Notation (PyON)
2008/11/5 Arnaud Delobelle wrote:
(or one could use given=dict(lst=lst, d=d))
This would have two advantages:
* eliminate the rist of keyword argument name collision * one could put all the 'given' objects in a dictionary and then 'pickle' expressions as needed using this method. Later pyon.loads could be passed this dictionary so that the objects can be unpickled correctly.
I think this idea is good as it would make it possible to pickle some objects that contain unpicklable objects just by declaring them as 'given'.
I think it's reasonable. I will change the interface.
Also, what happens with types? E.g.
pyon.dumps([int, float, str])
I think it would be good if typenames were considered literals (like numbers and strings) so that the above returns '[int, float, str]' (and the same for user-defined types maybe). Yes, pyon can dump types too. One note: default rule for name resolving uses sys._getframe(1).f_globals and sys._getframe(1).f_locals. But you can change name resolver writing you own.
For example:
class C(object): pass ... pyon.loads("[int,bool,float,C]") [<class 'int'>, <class 'bool'>, <class 'float'>, <class '__main__.C'>]
pyon.dumps([int,bool,float,C]) '[int,bool,float,C]'
Best regards, Zaur
participants (1)
-
Zaur Shibzoukhov