You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would it be possible to add iterator support, writing a Python "generator" as a Nim "iterator"? In my estimation, this would allow for more efficient Nim based Python libraries to be exported, rather than having to completely iterate and return a full dataset at instantiation, the iterator can lazily load when the next item is needed.
Proposal of requested functionality:
# test_lib.nimimport nimpy, tables, json
iteratormyRange*(s, e: int): int {.exportpy.} =for num in s .. e:
yield num
iteratorloadJSON*(s: string): Table[string, string] {.exportpy.} =var t =initTable[string, string]()
for i inparseJson(s):
for key, val in i:
t[key] =$val
yield t
Something I noticed in my testing on my PCPC repo is that it comes in as type class whereas a native Python generator comes in as type generator. A Nuitka generator shows type compiled_generator. This could be only due to semantics, but I'm wondering if this affects performance.
Do you know?
Implementing a generator / iterator in each of these solutions yields the following:
Would it be possible to add iterator support, writing a Python "generator" as a Nim "iterator"? In my estimation, this would allow for more efficient Nim based Python libraries to be exported, rather than having to completely iterate and return a full dataset at instantiation, the iterator can lazily load when the next item is needed.
Proposal of requested functionality:
The text was updated successfully, but these errors were encountered: