Re: experimenting with pointers and slices

2017-12-08 Thread Udiknedormin
@Araq Thank you, I didn't know that (I don't really use Nim's parallel capabilities). That's something new for me, especially comparing to how it works in, say, Rust.

Re: experimenting with pointers and slices

2017-12-07 Thread Araq
That is correct, yes.

Re: experimenting with pointers and slices

2017-12-06 Thread Udiknedormin
@Araq Do you mean the slices have to be passed directly, without a local binding?

Re: experimenting with pointers and slices

2017-12-03 Thread Araq
Seqs own the data they contain, views don't, conceptually there is no safe way to create a seq from a view without a copy. You can pass zero-copy slices in a `parallel` statement [https://nim-lang.org/docs/manual.html#parallel-spawn-parallel-statement](https://nim-lang.org/docs/manual.html#paral

Re: experimenting with pointers and slices

2017-12-03 Thread Udiknedormin
@jzakiya Too bad there is no seq constructor from raw pointer and size. This way, you could just make seq which is, in fact, a view of another seq. Hypothetical example: var s = @[3,1,4,1,5,9,2] var v = ptrToSeq(s[2].addr, 3) assert(v == @[4,1,5])

Re: experimenting with pointers and slices

2017-12-03 Thread mratsim
Don't forget that Nim seqs are copy on assignment If you want slices that share memory you will have to use shallowCopy similar to the following: var seg_r: seq[uint8] shallowCopy(seg_r, seg[slice]) `seg[slice]` might be creating a copy as well so maybe checked what is don

experimenting with pointers and slices

2017-12-03 Thread jzakiya
I have some working code and **I'm experimenting** with using pointers and slices to achieve the same results. Here's what I conceptually want to do. parallel: for bytn in 0..bprg-1: . var seg_r: seq[uint8] = seg[bytn*Ks..byt*Ks+Ks-1] spaw