News for hackers. Stuff that matters.
Re:Python consumes a lot of memory – how to reduce the size ... by erdewit on Wednesday July 10, 2019 @11:34AM (#20402951)
In the pure Python cases the 8 bytes per attribute are just pointers. The x, y and z are themselves full-blown objects with all the extra memory overhead that comes with it and this is not counted in the article. For example, an int object uses 28 bytes, so three of them already use up more than each of the described container objects.

The Cython and Numpy cases directly store the actual data and this has the larger effect to reduce memory.

Re:Python consumes a lot of memory – how to reduce the size ... by spott on Wednesday July 10, 2019 @01:17PM (#20404070)
On the other hand, the first 256 integers are singletons in python, so they aren't duplicated.
Re:Python consumes a lot of memory – how to reduce the size ... by mswtk on Wednesday July 10, 2019 @02:11PM (#20404669)
Slightly pedantic correction: This is a performance optimization in CPython. I wouldn't be surprised if other implementations have something similar, but to my best knowledge, this behaviour isn't part of the standard.
Re:Python consumes a lot of memory – how to reduce the size ... by merlincorey on Wednesday July 10, 2019 @05:37PM (#20406841)
> ... but to my best knowledge, this behaviour isn't part of the standard.

To the best of my knowledge, Python isn't one such language with a standard, is it?

Re:Python consumes a lot of memory – how to reduce the size ... by ben509 on Wednesday July 10, 2019 @11:03PM (#20408783)
The standard is documented in PEPs[1]. CPython is the flagship implementation, and many PEPs discuss it directly, but if you're looking to write another Python, that's where you'd go.

https://www.python.org/dev/peps/

Re:Python consumes a lot of memory – how to reduce the size ... by hermitdev on Wednesday July 10, 2019 @01:34PM (#20404276)
0-255 (inclusive) are singletons, just to clarify.
Re:Python consumes a lot of memory – how to reduce the size ... by saagarjha on Wednesday July 10, 2019 @01:49PM (#20404438)
Re:Python consumes a lot of memory – how to reduce the size ... by hermitdev on Wednesday July 10, 2019 @02:01PM (#20404573)
my bad. Maybe it used to be 0-255 and I'm just too old to remember the change?
Re:Python consumes a lot of memory – how to reduce the size ... by sametmax on Wednesday July 10, 2019 @02:36PM (#20404946)
Same for dictionaries ain't it ?