Re:Removing Python 2.x support from Django for version 2.0
by Buttons840 on Thursday January 19, 2017 @12:02PM
(#13437301)
> Dictionaries with guaranteed ordering.
I don't think you're suppose to depend on the ordering of dictionaries. It's an implementation detail which might get changed, although it wont actually ever be changed because people will come to depend on it.
Re:Removing Python 2.x support from Django for version 2.0
by bmh100 on Thursday January 19, 2017 @01:05PM
(#13437870)
I'm specifically referring to OrderedDict in this case, which does have guaranteed, insertion-based ordering. It was introduced in 3.1, circa 2009, via PEP 372.
Re:Removing Python 2.x support from Django for version 2.0
by wolf550e on Thursday January 19, 2017 @01:20PM
(#13438033)
https://docs.python.org/2/library/collections.html#ordereddi...
> New in version 2.7.
Re:Removing Python 2.x support from Django for version 2.0
by bmh100 on Thursday January 19, 2017 @01:26PM
(#13438090)
That's a good point. I didn't realize that it was also introduced into 2.7 at the same time.
Re:Removing Python 2.x support from Django for version 2.0
by thecardcheat on Thursday January 19, 2017 @12:16PM
(#13437403)
> I don't think you're suppose to depend on the ordering of dictionaries. It's an implementation detail which might get changed, although it wont actually ever be changed because people will come to depend on it.
I came here to make the same distinction - though I will say I hope you are wrong about people coming to depend on it when OrdereredDict is still there for a reason. The docs still plainly state that Dict should be considered un-ordered and do not make mention of this implementation detail (nor should they).
Re:Removing Python 2.x support from Django for version 2.0
by dr_zoidberg on Thursday January 19, 2017 @02:22PM
(#13438677)
You forgot functools.lru_cache. I've found in some Python 2.7 projects you can speed things up with a hacky dictionary-cache, but the proper functools.lru_cache gives better results and is far more flexible.
Re:Removing Python 2.x support from Django for version 2.0
by nodamage on Thursday January 19, 2017 @04:14PM
(#13439557)
Like many database-backed apps performance is currently limited by I/O, and memory is limited based on the size of the data sets I load (machine learning). A faster, lower memory Python does sound nice but I'm not sure how much effect it would actually have in real life.
How much faster might your code run just by upgrading to Python 3? How much memory might you save?