kopia lustrzana https://github.com/micropython/micropython-lib
pickle: Add trivial pickle implementation using repr()/exec().
rodzic
b975f8652c
commit
dffb8ac59b
|
@ -0,0 +1,14 @@
|
||||||
|
def dump(obj, f):
|
||||||
|
f.write(repr(obj))
|
||||||
|
|
||||||
|
def dumps(obj):
|
||||||
|
return repr(obj)
|
||||||
|
|
||||||
|
def load(f):
|
||||||
|
s = f.read()
|
||||||
|
return loads(s)
|
||||||
|
|
||||||
|
def loads(s):
|
||||||
|
d = {}
|
||||||
|
exec("v=" + s, d)
|
||||||
|
return d["v"]
|
|
@ -0,0 +1,14 @@
|
||||||
|
import sys
|
||||||
|
# Remove current dir from sys.path, otherwise distutils will peek up our
|
||||||
|
# module instead of system.
|
||||||
|
sys.path.pop(0)
|
||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
setup(name='micropython-pickle',
|
||||||
|
version='0.0.1',
|
||||||
|
description='pickle module to MicroPython',
|
||||||
|
url='https://github.com/micropython/micropython/issues/405',
|
||||||
|
author='Paul Sokolovsky',
|
||||||
|
author_email='micro-python@googlegroups.com',
|
||||||
|
license='MIT',
|
||||||
|
py_modules=['pickle'])
|
|
@ -0,0 +1,7 @@
|
||||||
|
import pickle
|
||||||
|
import sys
|
||||||
|
import io
|
||||||
|
|
||||||
|
pickle.dump({1:2}, sys.stdout)
|
||||||
|
|
||||||
|
print(pickle.loads("{4:5}"))
|
Ładowanie…
Reference in New Issue