Skip to content
/ unpython Public
forked from Mark-Boger/unpython

Read python pickle files to common lisp

Notifications You must be signed in to change notification settings

CL98K/unpython

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

unpython

Read pickled python object structures into Common Lisp.

Only tested on SBCL

Using

CL-USER> (unpython:load-pickle "<path to project>/t/data/character_list.pkl")
("a" "b")
CL-USER> (unpython:load-pickle "<path to project>/t/data/large_dict.pkl")
#<HASH-TABLE :TEST EQUAL :COUNT 21241 {1001A1B873}>
CL-USER> 

Extending

This structure may (will probably) change

To modify how unpython reads in a specific op-code change the perform-op method for that code.

(defmethod perform-op ((op-code (eql +empty-list+)) stream)
    (print "Hello World."))

This will print Hello World every time the +empty-list+ op-code is seen.

There's a wrapper macro to get rid of some of the boiler plate.

(do-for +empty-list+ ()
    (print "Hello World."))

When you give () after the op-code you ignore the stream. If you give (<symbol>) then you can pass that as a handle for the passed stream.

(do-for +empty-list+ (stream)
    (read-byte stream))

Implemented

  • Strings
    • Unicode currently has a naive implementation so it is unsafe
  • Dictionaries
  • Lists

TODO

  • Implement other types. (Added as needed)
  • Actually do error handling.

License

Do whatever I don't really care.

About

Read python pickle files to common lisp

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Common Lisp 89.5%
  • Shell 10.5%