News for hackers. Stuff that matters.
Re:Python 3.7: Introducing Data Classes by xapata on Wednesday April 18, 2018 @10:27PM (#16872887)
That's a silly example. If you're making billions of integers, use NumPy. If it's just one pass, use a generator. If you're making lots of objects with more interesting attributes, the attribute storage will overwhelm the difference the instance dicts make.

My point was not that __slots__ does nothing, but that there are more important things to worry about.

Re:Python 3.7: Introducing Data Classes by marvy on Wednesday April 18, 2018 @11:04PM (#16873044)
Suppose I want to run algorithms on large arrays of 2D points while maximizing readability. I want to store the x and y coordinates using Python integers so I don't have to worry about overflow errors, but I expect that most of the time the numbers will be small and this is "just in case".

I claim that in this case, __slots__ is exactly the right thing to worry about.

Re:Python 3.7: Introducing Data Classes by xapata on Wednesday April 18, 2018 @11:44PM (#16873174)
It's hard for me to imagine that situation coming up, but yes, __slots__ does indeed have a purpose.

BTW, have you considered using the complex type to handle that for you? It's 2d and ints should be safe in float representation. If it overflows it'll crash nicely.

Re:Python 3.7: Introducing Data Classes by marvy on Thursday April 19, 2018 @11:07PM (#16881895)
Good one. But let's say I want something mutable, so complex won't do.