76

New features planned for Python 4.0

 5 years ago
source link: https://www.tuicool.com/articles/VzQZRbZ
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

May 17, 2019 10:41 / django python /

With the release of Python 3.8 coming soon, the core development team has asked me to summarize our latest discussions on the new features planned for Python 4.0, codename "ouroboros: the snake will eat itself". This will be an exciting release and a significant milestone, many thanks to the hard work of over 100 contributors.

  • After heated debate on the mailing list, the 79-character line limit prescribed by PEP8 will be updated. IDE users all over the world will now be able to take advantage of their 30" ultra-wide 4K monitors, as the recommended line length will be increased to 89.5 characters (this was a compromise with the 100-character lobby, the decision being to split the difference).
  • All new libraries and standard lib modules must include the phrase "for humans" somewhere in their title, and have a splashy documentation page with lots of fonts typography and testimonials.
  • Finally, a new string-type for the masses, Python 4.0 will feature "z-strings": C-style NULL terminated bytestrings. Just prefix your string with z'my string' and Python will automatically ensure it is NULL-terminated. Note: the new z -strings cannot be used with any of the existing APIs that take string arguments - they must first be decoded to unicode strings or cast to bytes .
  • Type-hinting has been extended to provide even less tangible benefits, besides cluttering up the code and making it impossible to read. This new and "nerfed" type hinting will be called type whispering .
  • Fuck it we're going to just vendor libuv to provide the event loop for Twisted asyncio .
  • You can now use the async keyword before every single other keyword in the Python language, and we encourage you to async do so . There's nothing wrong with cargo-culting some magic keywords all over the place -- you want to go fast, don't you?
  • In addition to namedtuple and dataclasses (3.7), Python 4.0 will include several new thousand line decorator-hacks to implement simple struct types.
  • The GIL has been removed.
  • Just kidding! Instead we've been focusing all our effort on making it easier to juggle multiple interpreter data-structures within a single thread. No, no, you can thank us later!
  • The bytes -vs- str thing kept many of us employed as we had convinced our companies they needed to upgrade to Python 3. In the same spirit, we are excited to announce that there will now be two int types -- int will be a 32-bit signed integer, and long will be a 64-bit signed integer. But before you say, "hey, they did that in Python 2!", we'd like to add that you can no longer use int anywhere, and will need to convert them all to long .
  • Based on the overwhelming success of the 2to3 utility, we plan to release a 3to4 tool that will automatically convert your code to utilize these exciting new features.

Notably absent from 4.0, with much sadness, the following features did not make the cut:

  • After attempting to rewrite portions of the interpreter with Rust, nobody could figure out how to disable the borrow-checker, so we gave up.
  • No switch statement, no pattern-matching, and yes, yes, I know you can use a dict to do dispatching.
  • concurrent.Pasts and concurrent.Present will not be merged in time for this release as nobody can figure out what they're supposed to do.
  • Since nobody understands how twisted asyncio works, we are unable to offer any improvements at this time. The PSF now recommends all new projects to use gevent .
  • Unfortunately we will not be able to offer any improvements to the packaging "situation", may the battle rage on until the world burns or the sun freezes.

We look forward to this release, and will do everything in our power to ensure it takes us several minor versions before it is even remotely usable.

mieMjmB.png!web


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK