And it's said that Mozilla will kill pymake, is there any significance for the pymake work?
On Tue, Jul 1, 2014 at 5:17 AM, Gregory Szorc <g...@mozilla.com> wrote: > On 6/30/14, 2:06 PM, Kim Gräsman wrote: > >> Hi all, >> >> I'm working on making pymake Python 3-compatible, while still >> maintainin Python 2 support (work in progress here: >> https://github.com/mozilla/pymake/) >> >> I've addressed most minor issues, but there's two I don't feel >> comfortable with: dict.iteritems() vs dict.items() and range vs. >> xrange. >> >> In Python 3, items(), keys() and values() on dict no longer return >> lists, but rather lazy generators. The same goes for range(), it's now >> lazy and assumes the behavior of Python 2's xrange(), which no longer >> exists. >> >> This is nice, except it makes cross-compatible code much harder, since >> all functions exist in both Python versions but have very different >> semantics. >> >> I'm guessing you won't like the Python 2 code to always use eager >> items, keys, value and range, because it would take its toll on memory >> consumption and unnecessary copies. >> >> Do you have any ideas for version-agnostic patterns? >> > > The generally accepted solution is either: > > 1) Use 2to3 to produce a copy of the code that is Python 3 compatible and > then run the copy > 2) Use six [1] (or similar compatibility layer) to abstract iteritems, etc > > I'm a huge fan of a single code base without a 2to3 copy. I also prefer to > not introduce six or similar shims unless it's absolutely necessary: I'd > rather the code be readable, vanilla Python. > > If there is no or a small performance hit switching iteritems() and > friends to their non-iter-on-python-2 equivalents, I'm fine with doing > that. Have you measured the differences on a real project (such as Firefox)? > > [1] http://pythonhosted.org/six/ > > > _______________________________________________ > dev-builds mailing list > dev-builds@lists.mozilla.org > https://lists.mozilla.org/listinfo/dev-builds > -- Best Regards, xunxun
_______________________________________________ dev-builds mailing list dev-builds@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-builds