Comments (10)
Ok. I'll look at this again. It seems I did make the wrong conclusion. After review I'll fix anything that needs to be fixed.
Thanks!!
from gotraining.
OMG! How did I miss that when I was reviewing this post :(
THANK YOU for finding this and creating an issue. Can you please send me an email. [email protected]. I would like to give you access to the Go Bundle.
I should have a fix in the next hour.
from gotraining.
Your code example is not using the slices API at all?
Your 3 index slice examples are a smell. I have never found a reason for the last two values not to be the same.
from gotraining.
Sorry, I may be wasn't clear enough.
Here is the code with slices API, basically expressing the same idea.
package main
import (
"fmt"
"slices"
)
func main() {
var arr [10000]int
fmt.Println("arr", &arr[0])
fmt.Printf("Len(%d), Cap(%d)\n", len(arr), cap(arr))
slArr := arr[:10]
fmt.Println("slArr", &slArr[0])
fmt.Printf("Len(%d), Cap(%d)\n", len(slArr), cap(slArr))
slArr = slices.Clip(slArr)
fmt.Println("slArr", &slArr[0])
fmt.Printf("Len(%d), Cap(%d)\n", len(slArr), cap(slArr))
}
This code shows that the underlying array for slArr
after slices.Clip
doesn't change.
It's still the array taking O(10000) memory.
The Figure 3 of the post shows that after list = slices.Clip(list)
new list
slice points to the new underlying array with smaller size.
Figure 3 shows the slice value and underlying array after the clip operation.
So in case of the code above it would mean that slArr
after slices.Clip
points to a new array taking O(10) memory.
May be you meant smth else with Figure 3, but at least that's how I read it. And probably other readers of your post can read it in the same way. For me it looked like slices.Clip
makes a new slice with new underlying array of (probably) smaller size and copies elements from the original slice. This probably can lead to a wrong opinion that slices.Clip
can be used to save allocated memory of a process and free some memory to be garbage collected.
from gotraining.
I am happy to help :)
from gotraining.
I've sent you an email, btw. May be you need to check your spam folder.
from gotraining.
I've been out for a few days but I don't see it. Can you send it again please.
from gotraining.
Done ✅
from gotraining.
What is your email?
from gotraining.
from gotraining.
Related Issues (20)
- Funny unconscious impersonification of a rapper by William Kennedy HOT 2
- reading: "Errors are handled in return values" links to google+ HOT 5
- Additional Book HOT 1
- 【about Nanosecond 】 HOT 5
- slice.Min() and slice.Max() don't account for nil or empty slices HOT 3
- Builder msh
- use printGeneric instead of print in the 01-function section HOT 1
- [simulations] Use rand with non-fixed seed. HOT 2
- Release Note for 1.17 HOT 2
- link broken in README.md HOT 1
- Gopher Slack Invite Link Expired HOT 1
- Sharing variable up the call stack HOT 1
- Video is private HOT 2
- Inner type promotion HOT 1
- Outdated link HOT 1
- Compilation error in example HOT 1
- Link to Pikes 5 rules is wrong HOT 2
- Link unreachable on cpp.sh HOT 2
- Chapter composition for Go HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gotraining.