[Tutor] How can one know if a Python behavior is meant to be a maintained feature or just an implementation artifact?

Mats Wichmann mats at wichmann.us
Fri Oct 25 17:36:27 EDT 2019


On 10/25/19 1:37 PM, boB Stepp wrote:

>> If you want to be more sure you can use an OrderedDict - that works for
>> all versions.
> 
> I am mildly surprised that this now remains in the standard library.
> Is this solely for pre-version 3.6 compatibility concerns?  Is the
> game plan to eventually deprecate OrderedDict and later remove it?

I would assume so, but you can also just stop using it...

See:

https://twitter.com/raymondh/status/773978885092323328

>> Normally the official documentation will take pains to tell you - if
>> some behavior should not be counted on; and for that which can be
>> counted on, in which Python version it became official. ..
> 
> Hmm.  Seems there is room for some grayness here.  How many assumed
> behaviors are there in Python that are not explicitly documented, but
> have become second nature to developers?  I have no clue.  Just
> speculating... ~(:>))

It's a really good question (for any complex software system, not just 
Python).  In the case of Python, there are alternative implementations - 
and any time people try to "implement to the spec" it usually does a 
good job of flushing out assumptions vs. promises.  For Python, there 
have been quite a lot of these, this is not even a complete list:

- IronPython (Python running on .NET)
- Jython (Python running on the Java Virtual Machine)
- PyPy (A fast python implementation with a JIT compiler)
- Stackless Python (Branch of CPython supporting microthreads)
- MicroPython (Python running on micro controllers)

as well as in some ways Cython (wikipedia: Cython is a programming 
language that aims to be a superset of the Python programming language, 
designed to give C-like performance with code that is written mostly in 
Python with optional additional C-inspired syntax)

and it turns out that a good place to find out about such cases is to go 
to those projects' websites, because invariably somebody has done 
something that doesn't work there that did on good'ol CPython and then 
the research gets to happen on whether it's a bug or a CPython 
implementation detail.  And then the conclusion usually ends up in a FAQ 
or something.





More information about the Tutor mailing list