On Sunday, September 5, 2021 at 2:26:23 AM UTC-4 axel.wa...@googlemail.com wrote:
> On Sun, Sep 5, 2021 at 7:02 AM tapi...@gmail.com <tapi...@gmail.com> > wrote: > >> >> >> On Sunday, September 5, 2021 at 12:52:06 AM UTC-4 Kurtis Rader wrote: >> >>> On Sat, Sep 4, 2021 at 9:38 PM tapi...@gmail.com <tapi...@gmail.com> >>> wrote: >>> >>>> Why? That is an undocumented implementation detail. Furthermore, the >>>>> length of "x1" and "x2" at the time when they are appended to, in >>>>> combination with the value being appended, are reasonable predictors of >>>>> the >>>>> capacity of the new slice. It is up to you to prove that a different >>>>> heuristic performs better. >>>>> >>>> >>>> Are there some evidences to prove the current algorithm is better? >>>> >>> > There are two ways in which the current algorithm may be "better" than the > alternative: > • If the alternative is to always double, then the current algorithm saves > significant memory for large slices, which is better. > • The alternative is to use 1.25 starting at a different threshold (you > can't *always* use 1.25, as that would fail for n<4). Finding evidence of > whether this is better is easy: change the code, run the benchmarks, see > how they change. > > >> It is your responsibility to show that a different heuristic (not >>> "algorithm"). is better. >>> >> >> I have shown some examples above, which outputs will be more in line with >> exception >> if the heuristic will only depends on the sum length of the two arguments. >> > > Okay. Your expectation is wrong. What's the problem with that? > > I have *never* cared about how much `append` grows a slice. Not even > once. Even if I had cared to make a prediction and that prediction turned > out wrong, it would never have mattered. Why do you think it does? > No expectations are wrong, or right. They are like personal tastes. Personally, I think monotonically increasing is good taste. > > >> >> Clarification: I don't think the exponential growth algorithm is bad. >> I just think it should make the capacities increase monotonically. >> >> >>> >>> -- >>> Kurtis Rader >>> Caretaker of the exceptional canines Junior and Hank >>> >> -- >> > You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts...@googlegroups.com. >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/golang-nuts/8892db72-1392-4ee3-b336-5c64c6ef7f1cn%40googlegroups.com >> >> <https://groups.google.com/d/msgid/golang-nuts/8892db72-1392-4ee3-b336-5c64c6ef7f1cn%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/88b20816-3c6b-4830-af53-ed3b988d81e0n%40googlegroups.com.