4 ms·
If you're not using anyone P3k-incompatible libraries, and if you don't anticipate doing so in the future, and if you think you need something that is offered i
by kwantam 15y ago
If you're not using anyone P3k-incompatible libraries, and if you don't anticipate doing so in the future, and if you think you need something that is offered in 3.x that 2.7 doesn't offer, then it seems reasonable to go with 3.x.
For example, the 3.2+ GIL is far improved (and will not be backported, according to the bug tracker), so if you're using threads in Python, that's a good reason to go that way.
My impression is that most people can't really say with certainty that they'll never want to use an incompatible library in the future, so they'll stick with 2.7.x.
I just started a new project, went through this decision tree, and ended up at 2.7.
Game theory probably has something to say about the individual decision to defect (stay with 2.7 because it's more work to use 3.x) versus the public good that would come of using 3.x (i.e., more people use it, so library writers have more reason to support it, so more people can use it because it's better supported). Perhaps someone with more knowledge in this area can lend some insight into rearranging the incentives to make 3.x happen faster, too.
- SandB0x 15y agoThanks for the reply. I'm kind of torn. It would be nice to switch and forget about it, but Python is the language that works with absolutely everything. That's the biggest attraction. Libraries for everything, bindings for everything, APIs for everything. There are always purer and/or faster languages⁺, so why Python 3 over those if compatibly is poor? ⁺"There are only two kinds of languages: the kind everybody bitches about, and the kind nobody uses."
- lvh 15y agoThe dichtomy is false. Write good 2.x code and you will only miss a few very specific (like nonlocal) or recent features. You get the benefit of using all the existing 2.x libraries. Run 2to3 on your codebase and run your unit test suite, and see what happens. That way, once your dependencies are ported, you can be fairly sure that porting your library will be a walk in the park.
- d0m 15y agoThe ideal would be to be able to mix both versions. Use python3 by default and, by specifying an option somewhere, import from an older version. I.e. import-2.7 whatever-lib I know about features that aren't compatible (print as a function for instance), but what about python's bytecode.. ?
- hartror 15y agoI would hope/expect that to be even more incompatible than the syntax given the architectural changes made!