diff options
author | Stefan Israelsson Tampe <stefan.itampe@gmail.com> | 2018-02-21 13:57:57 +0100 |
---|---|---|
committer | Stefan Israelsson Tampe <stefan.itampe@gmail.com> | 2018-02-21 13:57:57 +0100 |
commit | 03e16c53f6579a969c285b89b8cb86140f1411a6 (patch) | |
tree | d47f3ee31040b7b11339fda849c090f0e2e16724 /modules/language/python/dict.scm | |
parent | 0a6079db826621c32cdfc89c3daea217582f0bb7 (diff) |
deepcopy copy works
Diffstat (limited to 'modules/language/python/dict.scm')
-rw-r--r-- | modules/language/python/dict.scm | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/modules/language/python/dict.scm b/modules/language/python/dict.scm index b9ab116..fe18583 100644 --- a/modules/language/python/dict.scm +++ b/modules/language/python/dict.scm @@ -6,6 +6,7 @@ #:use-module (language python def) #:use-module (language python for) #:use-module (language python exceptions) + #:use-module (language python persist) #:use-module (ice-9 match) #:use-module (ice-9 control) #:use-module (oop goops) @@ -39,6 +40,27 @@ (define H (hash 1333674836 complexity)) (define-class <py-hashtable> () t h n) + +(name-object <py-hashtable>) + +(cpit <py-hashtable> + (o (lambda (o h n a) + (slot-set! o 'h h) + (slot-set! o 'n n) + (slot-set! o 't + (let ((t (make-hash-table))) + (let lp ((a a)) + (if (pair? a) + (begin + (py-hash-set! t (caar a) (cdar a)) + (lp (cdr a))))) + t))) + (let ((t (slot-ref o 't))) + (list + (slot-ref o 'h) + (slot-ref o 'n) + (hash-fold (lambda (k v s) (cons (cons k v) s)) '() t))))) + (define (make-py-hashtable) (let* ((o (make <py-hashtable>)) (t (make-hash-table)) @@ -503,6 +525,8 @@ (slot-ref x 't))))))) __init__))) +(name-object dict) + (define (pyhash-listing) (let ((l (to-pylist (map symbol->string |