-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Discussion of Python 3.6 support #2415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
PEP 468, preserving the order of kwargs, is of particular interest to us because it might be hard to implement efficiently. CPython 3.6 will have dict == OrderedDict (ie all dicts are ordered), using the PyPy implementation to make it efficient. Essentially all dicts have 2 tables, one which is the ordered array of (key, value) pairs (ordered by order of insertion), and the other is a (compact) hash table that indexes the ordered array. |
I'd love to see "PEP 515 - Underscores in Numeric Literals" implemented. Easy and helpful. The rest, I'm more and more getting disappointed where CPython goes. 8000 |
+10. It would be pretty easy to add, and I agree really nice to then write something like |
+1 here too. I've been using that while coding in rust and while a bit odd at first, it makes reading the larger integers easier. |
Oh yes, oh yes. This is one my favourite language features in any language. I love it for hex and binary literals. Interestingly, at PyCon 2016 in Portland a few months ago, when the BDFL was reading over the list of PEP's, I cheered and applauded loudly for this one.... and about 2 thousand other people in the same room with me were dead silent. :/ So I'm thinking us embedded programmer types have different priorities. As to the rest, I'm thinking that preserving order in kwargs is hardly worth the expense of memory in Micropython, for as often as it is used. OTOH, it may be a forced march if it becomes important for code portability. OTOOH, since we have 'micro' versions of the important libraries anyway, perhaps porting is a given in any case. PEP530 just tickles me. Not sure it's of great value to Micropython, but I love it. (Yes, I'm back! Been away from Micropython since about last December. Sometimes, life happens, and good stuff falls below the cut-off line on the to-do list. Hopefully, Micropython can crawl back above the line for a while.) |
@dbc Welcome back! I don't follow your point about PEP530 though - improved async support is surely welcome. Many embedded applications rely on asynchronous code. |
@peterhinch re: PEP530 -- I should have been more clear about my fear of RAM bloat. Totally agree that asynch is great for embedded, I'm a big fan. I'd use async comprehensions if they were available, certainly -- like a cat on catnip. And of course we want Micropython to be as close to 100% source compatible with CPython as is practical. My fear is the "practical" part in Micropython -- if asynch comprehensions cause the SRAM footprint to grow significantly for programs using non-async list comprehensions or non-async generator expressions, then I'd be wary of it. Thinking about it... the semantics of an async comprehension are satisfied by just doing a normal comprehension. The completion order is arbitrary, after all. So maybe the syntax can be accepted but the functionality could be a normal comprehension. |
@dbc Will the availability of the async keyword affect the bytecode emitted when the keyword is absent? This surely depends on the cleverness of the compiler. But I'll leave this to people who actually understand compilers :) |
PEP 498 - Literal String Formatting. It's step forward and "replace both existing % and str.format" looks like best solution for me. Definitely I want it in µpy. |
PEP 498: I read that in detail now. So.. PEP 498 looks like the future. I never use %-formatting in new code. When PEP 498 strings happen in CPython, I will probably go exclusively to PEP498 format strings for new code and never look back, they are much more readable. @dpgeorge says " likely too much bloat " Ignoring PEP 498 means sacrificing CPython compatibility in a very visible way. Removing .format() in favor of literal string formatting is a very visible breaking change. Both of those options hit every user every day. My naive assumption would be that much of the low-level formatting code could be factored out of .format() and literal string formatting. Pre-processing the PEP 498 strings would add to the compiler, certainly. Or is it RAM bloat and not code bloat that is the concern? An f-string becomes a byte-code expression in RAM instead of a simple string. Is this the concern? I guess if you twisted my arm, I'd choose dropping %-formatting and .format() in favor of f-strings if I had to choose between f-strings and .format(). |
@dbc, one thing is pretty annoying. If you have only f-strings and got template from somewhere as string you should do something like >>> s = "{x}"
>>> x = 1
>>> eval(f"f'{s}'")
'1' |
You can still do: >>> s = "{x}"
>>> x = 1
>>> s.format(x=x) |
I see, I didn't catch that. In any case, they are not getting removed, so more power to you. Argh, and now I re-read the whole conversation, and see how stupid my comment is, sorry. |
Yes, that is somewhat klunky. |
I agree that removing .format() would be very bad news. Likewise the idea of removing the string modulus operator. In my view such changes would break far too much code and would be a worse departure from cPython compatibility than opting not to support f-strings. |
+1 For PEP 487 - Simpler customization of class creation This is deceptively humbly named. It is a MUCH saner and light-weight replacement for metaclasses in many cases. Also, it should be fairly simple to implement given that the machinery will be fairly similar to |
f-string is something I'd love to see in MicroPython |
Kill the .format() , voting for f-strings ! broken code is an abandoned code in 99% cases. I don't see any reason to not update the code for this change. |
I believe PEP-15 is implemented in at least 1.10. I think we can strike it through! |
PEP 515 (underscores in numeric literals) was implemented in 6a445b6 |
for those looking for another way to get f-strings, I've added better support to It has a PEP-498 compliant source transformer that produces equivalent |
thank you @asottile but sadly it seems, we won't benefit of bpo-36817 since asottile-archive/future-fstrings#40 was closed. Where is the "Discussion of Python 3 support" status ? i may have missed it. I hardly see any 3.x future support with notimpl on major language features ( including some that exist since 2.x ) i only found 3.5 #1329 |
that issue is still doable, I just don't really feel motivated to work on it -- if someone wants to pick it up then by all means do so :) |
For f-strings, did you see #4998 referenced above? |
@jimmo no i'm not searching for 3.6/3.7/3.8 totallly optionnal features from #4998 Apart from the warm thanks addressed to the person deserving them for adaptation ( after all he did not have to take the time to add that ) of his usefull tool for use with micropython in replacement of clumsy https://github.com/pmp-p/fstrings_helper my question was :
i only found 3.5 #1329, i'm more interested for discussion upon completion of 3.4 and reaching stability. |
Any chance to implement PEP 526 (Syntax for Variable Annotations (provisional))? I understand that it doesn't have any impact beyond the parser but would be hugely beneficial in development (at least to me it would be). I guess if it is too much work then using strip-hints is an option. Running it on each script before uploading/freezing would be an acceptable workaround if it works reliable. |
Yes I would like to see this implemented soon. It would then allow more sophisticated type hinting, and can also get use in viper annotations. |
Uh oh!
There was an error while loading. Please reload this page.
Python 3.6 beta 1 was released on 12 Sep 2016, and a summary of the new features can be found here: https://docs.python.org/3.6/whatsnew/3.6.html . Being in beta stage means we can provide feedback on any of the new features/changes if we like.
(See #1329 for Python 3.5 support, which is still pending.)
New syntax features:
New built-in features:
Standard library changes:
CPython internals (not exposed at the Python level so not relevant to uPy):
Linux/Windows changes:
Other Language Changes
global
ornonlocal
statement must now textually appear before the first use of the affected name in the same scope. Previously this was a SyntaxWarning.None
to indicate that the corresponding operation is not available. For example, if a class sets__iter__()
toNone
, the class is not iterable."[Pre 8000 vious line repeated {count} more times]"
ModuleNotFoundError
when it cannot find a module. Code that currently checks for ImportError (in try-except) will still work.super()
will now work correctly when called from metaclass methods during class creation.Changes to MicroPython built-in modules
array.array
will now stay exhausted even if the iterated array is extended.b2a_base64()
function now accepts an optional newline keyword argument to control whether the newline character is appended to the return value.cmath.tau
(τ) constant has been added.cmath.inf
andcmath.nan
to matchmath.inf
andmath.nan
, and alsocmath.infj
andcmath.nanj
to match the format used by complex repr.Collection
abstract base class has been added to represent sized iterable container classes.Reversible
abstract base class represents iterable classes that also provide the__reversed__()
method.AsyncGenerator
abstract base class represents asynchronous generatorsnamedtuple()
function now accepts an optional keyword argument module, which, when specified, is used for the__module__
attribute of the returned named tuple class.namedtuple()
are now keyword-only.collections.deque
instances can now be pickled.hashlib
supports OpenSSL 1.1.0. The minimum recommend version is 1.0.2.blake2b()
andblake2s()
are always available and support the full feature set of BLAKE2.sha3_224()
,sha3_256()
,sha3_384()
,sha3_512()
, and SHAKE hash functionsshake_128()
andshake_256()
were added.scrypt()
is now available with OpenSSL 1.1.0 and newer.json.load()
andjson.loads()
now support binary input. Encoded JSON should be represented using either UTF-8, UTF-16, or UTF-32.math
andcmath
modules.os
andos.path
modules now support path-like objects.close()
method allows explicitly closing ascandir()
iterator. Thescandir()
iterator now supports the context manager protocol.os.urandom()
now blocks until the system urandom entropy pool is initialized to increase the security.getrandom()
syscall (get random bytes) is now exposed as the newos.getrandom()
function.'(?i:p)ython'
matches'python'
and'Python'
, but not'PYTHON'
;'(?i)g(?-i:v)r'
matches'GvR'
and'gvr'
, but not'GVR'
.__getitem__
, which is equivalent togroup()
. Somo['name']
is now equivalent tomo.group('name')
.ioctl()
function now supports theSIO_LOOPBACK_FAST_PATH
control code.getsockopt()
constantsSO_DOMAIN
,SO_PROTOCOL
,SO_PEERSEC
, andSO_PASSSEC
are now supported.setsockopt()
now supports thesetsockopt(level, optname, None, optlen: int)
form.AF_ALG
to interface with Linux Kernel crypto API.ALG_*
,SOL_ALG
andsendmsg_afalg()
were added.TCP_USER_TIMEOUT
andTCP_CONGESTION
were added.ssl
supports OpenSSL 1.1.0. The minimum recommend version is 1.0.2.SSLContext
has better default configuration for options and ciphers.SSLSession
class. TLS session resumption can speed up the initial handshake, reduce latency and improve performance.get_ciphers()
method can be used to get a list of enabled ciphers in order of cipher priority.IntEnum
andIntFlags
.SSLContext
were added.SSLContext.post_handshake_auth
to enable andssl.SSLSocket.verify_client_post_handshake()
to initiate TLS 1.3 post-handshake authentication.'e'
format specifier.getfilesystemencodeerrors()
function returns the name of the error mode used to convert between Unicode filenames and bytes filenames.compress()
anddecompress()
functions now accept keyword arguments.(Changes to non-built-in modules will need to be documented elsewhere.)
The text was updated successfully, but these errors were encountered: