How to iterate over a sequence using a pointer to avoid making copies of every item

2023-11-19 Thread Araq
It does not copy. But usually people use `ref object` for big objects anyway out of habit.

How to iterate over a sequence using a pointer to avoid making copies of every item

2023-11-19 Thread billtubbs
Ah, I think I found the answer to my own question [here](https://forum.nim-lang.org/t/2721). So is the loop variable by default immutable? And therefore not a copy probably.

How to iterate over a sequence using a pointer to avoid making copies of every item

2023-11-19 Thread ElegantBeef
type Person = object name: string age: int data: array[0.., int] # big data proc getNames(people: openArray[Person]): seq[string] = for val in people.items: echo cast[int](val.data.addr) result.add val.name var a = [Per

How to iterate over a sequence using a pointer to avoid making copies of every item

2023-11-19 Thread billtubbs
I'm completely new to Nim so go easy on me here. My goal is to replace performance-limiting parts of Python scripts (using Nimpy and Nimporter) and so part of the appeal is that it is a high level language with similar syntax and idioms to Python. First impressions are great... but then I tripp