Live data from Hacker News

Guide to Data Classes in Python 3.7

realpython.com

31–40 of 48 posts

Re: Guide to Data Classes in Python 3.7

#31
post #20
post #9

Earlier quoted context omitted.

Python 2.7 has been stable and supported for almost 8 years -- how much more long term do you want? Even releases of Java only seem to get about 6 years of support.

> Python 2.7 has been stable and supported for almost 8 years -- how much more long term do you want? Forever? 2.x codebase are in the millions of lines of code in companies, and they won't be converted or go away anytime soon. And those will need security updates and bug fixes. Note that Google and Dropbox are still running tons of Python 2.x -- and those are two companies where Guido Vas Rossum himself has worked i…

And FORTRAN, C, C++... all languages with ISO standards. But with Python, the current version of the main implementation is the standard.

Re: Guide to Data Classes in Python 3.7

#32
post #20
post #9

Earlier quoted context omitted.

Python 2.7 has been stable and supported for almost 8 years -- how much more long term do you want? Even releases of Java only seem to get about 6 years of support.

> Python 2.7 has been stable and supported for almost 8 years -- how much more long term do you want? Forever? 2.x codebase are in the millions of lines of code in companies, and they won't be converted or go away anytime soon. And those will need security updates and bug fixes. Note that Google and Dropbox are still running tons of Python 2.x -- and those are two companies where Guido Vas Rossum himself has worked i…

Cobol, Fortran 77, ANSI C and stuff like that lasted a long time -- but they didn't have batteries-included standard libraries, and there was no expectation that they would be maintained against things such as security threats. That just wasn't part of the design of a programming language at the time.

(Can a classic programming language specification have a security hole? Absolutely. Consider the case of gets() from C.)

Re: Guide to Data Classes in Python 3.7

#33
post #9

Earlier quoted context omitted.

Python 2.7 has been stable and supported for almost 8 years -- how much more long term do you want? Even releases of Java only seem to get about 6 years of support.

Perl 5 runs well after... twenty five years?

And Python 2 has run for 18, if we're counting by major versions. Heck, as long as you're okay with little changes like booleans not looking like integers anymore, you can run your Python 1 code 24 years later.

But imagine if Python followed the example of Perl. Python 3 becomes a curious side project, everyone moves back to Python 2, which goes on for decades without new features. At last, Python can have all the popularity and relevance of... Perl 5?

Re: Guide to Data Classes in Python 3.7

#34
post #20

Earlier quoted context omitted.

> Python 2.7 has been stable and supported for almost 8 years -- how much more long term do you want? Forever? 2.x codebase are in the millions of lines of code in companies, and they won't be converted or go away anytime soon. And those will need security updates and bug fixes. Note that Google and Dropbox are still running tons of Python 2.x -- and those are two companies where Guido Vas Rossum himself has worked i…

> Forever? You can have support forever. You just can't have it __for free__ forever. There are companies out there that will happily sell you the service. You already get an amazing tech for free, and support of 2 decades in you take all the 2.X branch in consideration (e.g: 4 times the ubuntu LTS). You complaining at this point is just insulting the community. I find it infuriating. When the JS or Ruby community br…

many companies have made much money from the free work of volunteers, yet those exploiting companies are blameless, while proponents of a useful and stable technology are glibly mocked?

Re: Guide to Data Classes in Python 3.7

#35
post #24
post #20

Earlier quoted context omitted.

> Python 2.7 has been stable and supported for almost 8 years -- how much more long term do you want? Forever? 2.x codebase are in the millions of lines of code in companies, and they won't be converted or go away anytime soon. And those will need security updates and bug fixes. Note that Google and Dropbox are still running tons of Python 2.x -- and those are two companies where Guido Vas Rossum himself has worked i…

Why 2.7? Why not 2.2? Why not 1.3? Why not 1.0? At some point you need to require others to update. Or they can hire consultants like companies do for Cobol.

Python 2.7 is stable and useful now.. it is a lot of C code implementing a scripting language. There are a lot of libraries that work well right now, that took hundreds of skilled years of work to build.

Re: Guide to Data Classes in Python 3.7

#36
post #24

Earlier quoted context omitted.

Why 2.7? Why not 2.2? Why not 1.3? Why not 1.0? At some point you need to require others to update. Or they can hire consultants like companies do for Cobol.

Python 2.7 is stable and useful now.. it is a lot of C code implementing a scripting language. There are a lot of libraries that work well right now, that took hundreds of skilled years of work to build.

The same can be said thousands of 16 bit applications that are no longer supported on 64-bit architecture. Python 2.7 isn't being deleted from the face of the Earth. You're just going to have to pay people to maintain your legacy codebase because after 10 years of knowing it will become obsolete you stuck with it.

Re: Guide to Data Classes in Python 3.7

#37
post #7
post #6

Earlier quoted context omitted.

On the __slots__, the article claims that these do: https://realpython.com/python-data-classes/#optimizing-data-... EDIT: From PEP 557: https://www.python.org/dev/peps/pep-0557/#support-for-automa... “Support for automatically setting __slots__? At least for the initial release, __slots__ will not be supported. __slots__ needs to be added at class creation time. The Data Class decorator is called after the class is c…

The article doesn't discuss slots and default values. Here's the actual reference implementation for dataclasses where it's discussed: https://github.com/ericvsmith/dataclasses/issues/28 Your second solution works fine (and is what I'd referenced). For your first solution, I'd again redirect you to my statement "they don’t support __slots__ and default values" and the above link.

It’s not my solution, just a direct quote from PEP.

Re: Guide to Data Classes in Python 3.7

#38
post #20

Earlier quoted context omitted.

> Python 2.7 has been stable and supported for almost 8 years -- how much more long term do you want? Forever? 2.x codebase are in the millions of lines of code in companies, and they won't be converted or go away anytime soon. And those will need security updates and bug fixes. Note that Google and Dropbox are still running tons of Python 2.x -- and those are two companies where Guido Vas Rossum himself has worked i…

> Forever? You can have support forever. You just can't have it __for free__ forever. There are companies out there that will happily sell you the service. You already get an amazing tech for free, and support of 2 decades in you take all the 2.X branch in consideration (e.g: 4 times the ubuntu LTS). You complaining at this point is just insulting the community. I find it infuriating. When the JS or Ruby community br…

>In 2020, I'll triple my price for any work on 2.7. I'm done being fair to people with such ingratitude.

This doesn't make any sense. You're not running a charity. If you can get customers with the tripled price, then do triple it. If you can get customers with a 100x price, you'd be a fool not to 100x your price.

If, on the other hand, you can't get customers for triple the price, then tripling it will just make people go to someone else. You're not hurting anybody either way...

Re: Guide to Data Classes in Python 3.7

#39
post #36

Earlier quoted context omitted.

Python 2.7 is stable and useful now.. it is a lot of C code implementing a scripting language. There are a lot of libraries that work well right now, that took hundreds of skilled years of work to build.

The same can be said thousands of 16 bit applications that are no longer supported on 64-bit architecture. Python 2.7 isn't being deleted from the face of the Earth. You're just going to have to pay people to maintain your legacy codebase because after 10 years of knowing it will become obsolete you stuck with it.

>The same can be said thousands of 16 bit applications that are no longer supported on 64-bit architecture.

And some of those are a big loss as well.

But most of them are obsolete and deprecated (because e.g. Office suites, OSes and gaming moved on) in a way that Python 2.x programs used in businesses are not.

Re: Guide to Data Classes in Python 3.7

#40

Data Classes are a cool feature, useful, and a superior alternative to namedtuple. But while this was brewing, attrs ate their lunch. Data Classes just don't go far enough compared to what attrs [1] has provided for a while now. If there's a compelling reason to switch, I haven't found it yet. Can I use Data Classes in a library supporting Python 2.7, 3.4-3.7? I don't think the answer is yes today. [1]: https://githu…

> Data Classes are a cool feature, useful, and a superior alternative to namedtuple. I'm curious, how is it "superior" to NamedTuples?

The PEP lists the rationale and some discussion.

https://www.python.org/dev/peps/pep-0557/#rationale https://www.python.org/dev/peps/pep-0557/#id10

Post reply on HN