[go-nuts] Re: slice of pointer of struct vs slice of struct

2017-10-20 Thread Feby Tanzil
hmm, suppose I have struct X that have 50 attributes that represent 50 cols in db, struct Y 4 attributes, 4 cols and I have : func FindX() *X {} func FindXs() []*X {} func FindY() *Y {} func FindYs() []*Y {} I don't care about mutable, since this is only a getter func, or should I care?

Re: [go-nuts] slice of pointer of struct vs slice of struct

2017-10-20 Thread Jan Mercl
On Fri, Oct 20, 2017 at 10:39 AM Ian Davis wrote: > How does that affect the size of []T or []*T ? No one said it does. What size of T affects is appending/inserting/deleting items to/from the slice. If one passes around a value of type []T, those operations are probably

Re: [go-nuts] slice of pointer of struct vs slice of struct

2017-10-20 Thread Bakul Shah
On Fri, 20 Oct 2017 09:09:15 - Jan Mercl <0xj...@gmail.com> wrote: Jan Mercl writes: > > On Fri, Oct 20, 2017 at 11:07 AM Bakul Shah wrote: > > > On the flip side, []*T will be less cache/TLB/GC friendly than > > []T, unless T is much larger than a ptr. You are also > >

Re: [go-nuts] slice of pointer of struct vs slice of struct

2017-10-20 Thread Bakul Shah
On Fri, 20 Oct 2017 08:49:16 - Jan Mercl <0xj...@gmail.com> wrote: Jan Mercl writes: > > On Fri, Oct 20, 2017 at 10:39 AM Ian Davis wrote: > > > How does that affect the size of []T or []*T ? > > No one said it does. What size of T affects is appending/inserting/deleting

[go-nuts] Re: A full-feature serialization package to replace std.binary released.

2017-10-20 Thread Dave Cheney
Thank you for sharing your package. Would you consider re-licencing it under a more permissive licence like MIT or BSD? On Friday, 20 October 2017 17:37:07 UTC+10, Ally Dale wrote: > > Hello, everyone, > It's my pleasure to announce that I have just released a stable version of > full-feature

Re: [go-nuts] slice of pointer of struct vs slice of struct

2017-10-20 Thread Ian Davis
On Fri, 20 Oct 2017, at 06:34 AM, Jan Mercl wrote: > On Fri, Oct 20, 2017 at 7:25 AM Feby Tanzil > wrote:> > > Which is better & preferable in Go? > > Depends on size of T. How does that affect the size of []T or []*T ? Ian -- You received this message because you are

Re: [go-nuts] slice of pointer of struct vs slice of struct

2017-10-20 Thread Jan Mercl
On Fri, Oct 20, 2017 at 11:07 AM Bakul Shah wrote: > On the flip side, []*T will be less cache/TLB/GC friendly than > []T, unless T is much larger than a ptr. You are also > allocating an extra pointer per element. For small slices it > probably doesn't matter much either

[go-nuts] Re: slice of pointer of struct vs slice of struct

2017-10-20 Thread Juliusz Chroboczek
>> What size of T affects is appending/inserting/deleting items to/from >> the slice. If one passes around a value of type []T, those operations >> are probably performed on the value. > On the flip side, []*T will be less cache/TLB/GC friendly than > []T, unless T is much larger than a ptr. On

[go-nuts] Re: slice of pointer of struct vs slice of struct

2017-10-20 Thread Tamás Gulácsi
Which is a good thing: you have to alter the slice explicitly: https://play.golang.org/p/KE2Davl06t When you pass a pointer, you also pass the right to modify the pointee - ownership. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Re: slice of pointer of struct vs slice of struct

2017-10-20 Thread Henrik Johansson
https://play.golang.org/p/xILWETuAii I have started to use non pointer slices much more as of late. Every time I bother measuring it is always faster and it is better for the GC (usually, caveats apply). It also, perhaps naively, feels safer... :) fre 20 okt. 2017 kl 13:41 skrev Juliusz

[go-nuts] Re: slice of pointer of struct vs slice of struct

2017-10-20 Thread Dave Cheney
That's a great way to think about it the 'cost' of copying vs passing the address. Thank you. On Friday, 20 October 2017 17:09:49 UTC+10, Feby Tanzil wrote: > > so if I have like 50 attributes then pointer is preferable then > How big is big? I took from >

[go-nuts] Re: slice of pointer of struct vs slice of struct

2017-10-20 Thread Feby Tanzil
so if I have like 50 attributes then pointer is preferable then How big is big? I took from https://github.com/golang/go/wiki/CodeReviewComments for receiver, is this applicable for this too? Assume it's equivalent to passing all its elements as arguments to the > method. If that feels too

Re: [go-nuts] slice of pointer of struct vs slice of struct

2017-10-20 Thread roger peppe
On 20 October 2017 at 05:15, Feby Tanzil wrote: > Hi, > > I got vague answers in the internet over this. > Which is better & preferable in Go? > > type T struct { > // some attributes > ... > } > > func a() []T { > > } > > func b() []*T { > > } Both are plausible. It

Re: [go-nuts] non-capturing group not working?

2017-10-20 Thread roger peppe
On 19 October 2017 at 16:01, wrote: > I add this for others having problems with non capture groups when using > regular expressions in google scripts: > > I struggled trying to debug why this simple regex would not work for me in > google application script:

[go-nuts] A full-feature serialization package to replace std.binary released.

2017-10-20 Thread Ally Dale
Hello, everyone, It's my pleasure to announce that I have just released a stable version of full-feature serialization package to replace std.binary. You can find the project here: https://github.com/vipally/binary My trouble is that when I want to transport a go data on network between golang

Re: [go-nuts] A full-feature serialization package to replace std.binary released.

2017-10-20 Thread Jan Mercl
On Fri, Oct 20, 2017 at 9:37 AM Ally Dale wrote: FTR: OP probably means encoding/binary where std.binary is written instead for unknown reasons. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

Re: [go-nuts] Re: slice of pointer of struct vs slice of struct

2017-10-20 Thread roger peppe
If I need to mutate elements of an array of by-value structs, I'll usually do this: https://play.golang.org/p/YUFsOkvKQ4 Then for most of the body of the loop, you can use i and t as if you'd ranged over pointers to elements of the slice (no need to explicitly assign to the element). On 20