python: word for converting python lists to vectors

db4
Björn Lindqvist 2014-01-30 20:46:55 +01:00 committed by John Benediktsson
parent 8ed7fe02ac
commit 715d426ad3
1 changed files with 4 additions and 3 deletions

View File

@ -115,6 +115,9 @@ ERROR: python-error type message ;
: py-tuple>array ( py-tuple -- arr )
dup py-tuple-size iota [ py-tuple-get-item ] with map ;
: py-list>vector ( py-list -- vector )
dup py-list-size iota [ py-list-get-item ] with V{ } map-as ;
GENERIC: (>py) ( obj -- obj' )
M: string (>py) utf8>py-unicode ;
M: math:fixnum (>py) PyLong_FromLong ;
@ -143,9 +146,7 @@ DEFER: >factor
{ "bool" [ PyObject_IsTrue 1 = ] }
{ "dict" [ PyDict_Items (check-return) >factor >hashtable ] }
{ "int" [ PyInt_AsLong ] }
{ "list" [
dup py-list-size iota [ py-list-get-item >factor ] with V{ } map-as
] }
{ "list" [ py-list>vector [ >factor ] map ] }
{ "long" [ PyLong_AsLong ] }
{ "str" [ PyString_AsString (check-return) ] }
{ "tuple" [ py-tuple>array [ >factor ] map ] }