This is the code example. if i omit the pragma "{.exportpy.}", the code compiles. but for nimpy i need to add that pragma and then the code doesn't compile. The compile error i get is : Error: invalid type: 'var seq[Table[system.int, system.int]]' for var
import nimpy
import tables
proc create_list(tablesList: var seq[Table[int, int]], oneTable: Table[int, int]): seq[Table[int, int]] {.exportpy.} =
tablesList.add(oneTable)
return tablesList
var arguments are not supported by nimpy. In the general case this would require two-way marshalling, which is usually unnecessarily expensive. As a better alternative you can use PyObject type, which is a lightweight reference to the underlying python whatever.
import nimpy
import tables
proc create_list(tablesList: PyObject, oneTable: Table[int, int]): PyObject {.exportpy.} =
discard tablesList.add(oneTable) # underlying python object should have `add` method
return tablesList