Re: [go-nuts] Re: Confused about heap usage for empty slices

2022-09-08 Thread 'Axel Wagner' via golang-nuts
There is a theoretical (but literally negligible in practice) difference in that the compiler has to write the pointer into the slice. But yes, realistically, there is no difference. On Thu, Sep 8, 2022 at 4:15 PM Mathew Murphy wrote: > Thanks. So basically, there's no memory benefit or performa

[go-nuts] Re: Confused about heap usage for empty slices

2022-09-08 Thread Mathew Murphy
Thanks. So basically, there's no memory benefit or performance benefit to using nil slices over empty slices -- it's ultimately just a matter of how you want them to serialize JSON or get written to databases? mathew On Wednesday, September 7, 2022 at 6:56:33 PM UTC-5 k...@google.com wrote: >

[go-nuts] Re: Confused about heap usage for empty slices

2022-09-07 Thread 'Keith Randall' via golang-nuts
(Actually, that address is an address on the stack, but that's only because the backing store for emptySlice does not escape. It should also take ~no space.) On Wednesday, September 7, 2022 at 4:53:12 PM UTC-7 Keith Randall wrote: > That address is not in the heap. It is the address of a specia

[go-nuts] Re: Confused about heap usage for empty slices

2022-09-07 Thread 'Keith Randall' via golang-nuts
That address is not in the heap. It is the address of a special word in the runtime, called runtime.zerobase, which is explicitly for this purpose. It is a place to point things that need to be non-nil but have no size. On Wednesday, September 7, 2022 at 12:01:28 PM UTC-7 me...@pobox.com wrote: