I think one thing that might be worth to add is that Django’s DjangoJSONEncoder also uses ‘Z’. This is the reason that I ended up here.
So it’s not just other popular languages like Javascript that uses the format. One of the most popular Python web frameworks uses it for JSON encoding datetimes.
I wanted to note that the replace('Z', '00+00') workaround makes parsing dates around 5x as slow (I ran a benchmark of various date parsing libraries and functions; see linked gist).
I think having a very fast ISO parsing function in the python standard library is important.
Date parsing benchmark (requires packages: pytest, pytest-benchmark, python-dateutil, ciso8601, iso8601)
So, it’s been awhile now and I wanted to ask if there is still a strong opposition to a minimal code and documentation patch adding support for Z?
We have to interact with other languages a lot and depending on third-party packages is very cumbersome for stdlib-only CI scripts and such.
Timezone stuff landing in Python was a huge deal, because we had to depend on third-party stuff in the past, and now we don’t have to anymore. Getting this small wart out of the way is a small step for Python developers, but a big step for humanity.
datetime.fromisoformat() is the inverse operation of datetime.isoformat(), which is to say that every valid input to datetime.fromisoformat() is a possible output of datetime.isoformat(), and every possible output of datetime.isoformat() is a valid input to datetime.fromisoformat().
I am not sure if I fully am in line with this objection. If “Z” is taken to denote the same referent as “00+00”, then the symmetry still stands:
Python has symmetrical functions datetime.fromisoformat() and datetime.isoformat(), which point to the same referent.
Python adds an ad-hoc rule to datetime.fromisoformat(), which makes this function recognize one input (strings ending with “Z”) as having the same referent as another (strings ending with “+00:00”).
Python now has symmetrical functions datetime.fromisoformat() and datetime.isoformat() which point to the same referent, but the former has been enriched with an ad-hoc rule.
Do Python developers want to avoid scenarios where "2014-12-10 12:00:00Z" is transformed into a Python object, which then gets translated back into a different string with the same referent "2014-12-10 12:00:00+00:00"? I personally see nothing wrong or asymmetrical with this conversion rule, since I cannot envision a scenario where this might cause problems further down the road. Are there any reasonable kind of scenarios where one would strictly expect a datetime object generated from a string with an explicit “Z” to never covert back to a string with an explicit “+00:00”?