News for hackers. Stuff that matters.
Re:The PEPs of Python 3.9 by a1369209993 on Thursday May 28, 2020 @07:25PM (#23344325)
> it also keeps the original string alive, so if you slurp in megabytes, slice out a few bytes you keep around and "throw away" the original string, that one is still kept alive by the substringing you perform, and you basically have a hard to diagnose memory leak due to completely implicit behaviour.

You can get around that with a smarter garbage collector, though. On every mark-sweep pass (which you need for cycle detection even if you use refcounts for primary cleanup), add up the number of bytes of distinct string objects using the buffer. If it's less than the size of the buffer, you can save memory by transparently mutating each substring to use it's own buffer. If it's not, then you actually are saving memory by sharing storage, so you should probably keep doing that.

Re:The PEPs of Python 3.9 by Doxin on Friday May 29, 2020 @02:28AM (#23346844)
The cpython mark-and-sweep garbage collector does very little on purpose. It basically only gets involved for reference cycles. Anything else is dealt with by reference counting. This way you prevent long GC pauses.
Re:The PEPs of Python 3.9 by a1369209993 on Friday May 29, 2020 @03:01AM (#23347025)
True, but that's by no means a inherent characteristic of garbage collectors, or even garbage collectors operating on objects of a python implementation in particular.
Re:The PEPs of Python 3.9 by Doxin on Friday May 29, 2020 @05:29AM (#23347990)
True, but that is the current philosophy behind the garbage collector in the most used python implementation and it's unlikely to change.
Re:The PEPs of Python 3.9 by masklinn on Friday May 29, 2020 @11:27AM (#23351079)
> You can get around that with a smarter garbage collector, though.

That complexifies the GC (already a complex beast) as it requires strong type-specific specialisation, more bookkeeping, and adds self-inflicted edge cases. Even the JVM folks didn't bother (though mayhaps they did not because they have more than one garbage collector).