News for hackers. Stuff that matters.
Re:Go is not an easy language by pansa2 on Monday February 22, 2021 @02:56AM (#26221945)
But when removing an item it’s not necessary to visit every element, just re-arrange the pointers (and in CPython, modify the reference count of the item that was removed).
Re:Go is not an easy language by sokoloff on Monday February 22, 2021 @07:44AM (#26223838)
When removing an item by value (being the use case in this thread), you do need to visit the elements to check the value.
Re:Go is not an easy language by hiptobecubic on Monday February 22, 2021 @10:02PM (#26233420)
Yes but the problem there is not that your list is backed by a linked list or an array, it's that every single value is boxed and needs dereferencing. The difference between no hops and one hop totally trumps one hop vs two hops.