Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #101592 > unrolled thread
| Started by | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| First post | 2016-01-13 18:30 +1100 |
| Last post | 2016-01-14 01:49 +0000 |
| Articles | 6 on this page of 66 — 25 participants |
Back to article view | Back to comp.lang.python
Stop writing Python 4 incompatible code Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-01-13 18:30 +1100
Re: Stop writing Python 4 incompatible code sjmsoft@gmail.com - 2016-01-13 06:21 -0800
Re: Stop writing Python 4 incompatible code Random832 <random832@fastmail.com> - 2016-01-13 11:25 -0500
Re: Stop writing Python 4 incompatible code Steven D'Aprano <steve@pearwood.info> - 2016-01-14 11:10 +1100
Re: Stop writing Python 4 incompatible code Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-01-13 22:40 -0200
Re: Stop writing Python 4 incompatible code Steven D'Aprano <steve@pearwood.info> - 2016-01-14 12:02 +1100
Re: Stop writing Python 4 incompatible code Michael Torrie <torriem@gmail.com> - 2016-01-13 18:24 -0700
Re: Stop writing Python 4 incompatible code Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-01-13 21:39 -0500
Re: Stop writing Python 4 incompatible code Gene Heskett <gheskett@wdtv.com> - 2016-01-13 21:59 -0500
Re: Stop writing Python 4 incompatible code Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-01-14 07:41 -0500
Re: Stop writing Python 4 incompatible code Peter Otten <__peter__@web.de> - 2016-01-14 14:43 +0100
Re: Stop writing Python 4 incompatible code "D'Arcy J.M. Cain" <darcy@VybeNetworks.com> - 2016-01-14 08:47 -0500
Re: Stop writing Python 4 incompatible code Peter Otten <__peter__@web.de> - 2016-01-14 16:32 +0100
Re: Stop writing Python 4 incompatible code "D'Arcy J.M. Cain" <darcy@VybeNetworks.com> - 2016-01-14 10:47 -0500
Re: Stop writing Python 4 incompatible code Peter Otten <__peter__@web.de> - 2016-01-14 17:52 +0100
Re: Stop writing Python 4 incompatible code Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-01-15 16:08 +1300
Re: Stop writing Python 4 incompatible code Chris Angelico <rosuav@gmail.com> - 2016-01-15 15:56 +1100
Re: Stop writing Python 4 incompatible code Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-01-16 10:02 +1300
Re: Stop writing Python 4 incompatible code Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-01-15 09:40 -0200
Re: Stop writing Python 4 incompatible code Robin Koch <robin.koch@t-online.de> - 2016-01-15 19:29 +0100
Re: Stop writing Python 4 incompatible code Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-01-15 16:43 -0200
Re: Stop writing Python 4 incompatible code Terry Reedy <tjreedy@udel.edu> - 2016-01-13 19:53 -0500
Re: Stop writing Python 4 incompatible code Rick Johnson <rantingrickjohnson@gmail.com> - 2016-01-13 17:02 -0800
Re: Stop writing Python 4 incompatible code Chris Angelico <rosuav@gmail.com> - 2016-01-14 12:29 +1100
Re: Stop writing Python 4 incompatible code Michael Torrie <torriem@gmail.com> - 2016-01-13 19:11 -0700
Re: Stop writing Python 4 incompatible code Rick Johnson <rantingrickjohnson@gmail.com> - 2016-01-13 18:51 -0800
Re: Stop writing Python 4 incompatible code Chris Angelico <rosuav@gmail.com> - 2016-01-14 14:08 +1100
Re: Stop writing Python 4 incompatible code Rick Johnson <rantingrickjohnson@gmail.com> - 2016-01-13 19:29 -0800
Re: Stop writing Python 4 incompatible code Michael Torrie <torriem@gmail.com> - 2016-01-13 22:18 -0700
Re: Stop writing Python 4 incompatible code Rick Johnson <rantingrickjohnson@gmail.com> - 2016-01-14 07:30 -0800
Re: Stop writing Python 4 incompatible code Chris Angelico <rosuav@gmail.com> - 2016-01-15 04:41 +1100
Re: Stop writing Python 4 incompatible code Rick Johnson <rantingrickjohnson@gmail.com> - 2016-01-14 10:40 -0800
Re: Stop writing Python 4 incompatible code <paul.hermeneutic@gmail.com> - 2016-01-14 13:16 -0700
Re: Stop writing Python 4 incompatible code Steven D'Aprano <steve@pearwood.info> - 2016-01-15 09:04 +1100
Re: Stop writing Python 4 incompatible code Rick Johnson <rantingrickjohnson@gmail.com> - 2016-01-14 15:16 -0800
Re: Stop writing Python 4 incompatible code Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-01-14 19:16 +1100
Re: Stop writing Python 4 incompatible code wxjmfauth@gmail.com - 2016-01-14 01:37 -0800
Re: Stop writing Python 4 incompatible code Terry Reedy <tjreedy@udel.edu> - 2016-01-14 00:45 -0500
Re: Stop writing Python 4 incompatible code Rick Johnson <rantingrickjohnson@gmail.com> - 2016-01-14 07:52 -0800
Re: Stop writing Python 4 incompatible code Ian Kelly <ian.g.kelly@gmail.com> - 2016-01-14 15:52 -0700
Re: Stop writing Python 4 incompatible code Rick Johnson <rantingrickjohnson@gmail.com> - 2016-01-14 15:55 -0800
Re: Stop writing Python 4 incompatible code Emile van Sebille <emile@fenx.com> - 2016-01-15 06:52 -0800
Re: Stop writing Python 4 incompatible code Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-01-16 09:49 +1300
Re: Stop writing Python 4 incompatible code Rick Johnson <rantingrickjohnson@gmail.com> - 2016-01-15 14:34 -0800
Re: Stop writing Python 4 incompatible code Rick Johnson <rantingrickjohnson@gmail.com> - 2016-01-15 13:45 -0800
Re: Stop writing Python 4 incompatible code William Ray Wing <wrw@mac.com> - 2016-01-15 12:02 -0500
Re: Stop writing Python 4 incompatible code Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-01-15 16:09 -0200
Re: Stop writing Python 4 incompatible code Alister <alister.ware@ntlworld.com> - 2016-01-15 18:46 +0000
Re: Stop writing Python 4 incompatible code Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-01-15 16:55 -0200
Re: Stop writing Python 4 incompatible code Alister <alister.ware@ntlworld.com> - 2016-01-16 14:41 +0000
Re: Stop writing Python 4 incompatible code Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-01-16 12:48 -0200
Re: Stop writing Python 4 incompatible code paul.hermeneutic@gmail.com - 2016-01-16 09:08 -0700
Re: Stop writing Python 4 incompatible code William Ray Wing <wrw@mac.com> - 2016-01-16 13:00 -0500
Re: Stop writing Python 4 incompatible code Michael Torrie <torriem@gmail.com> - 2016-01-16 12:26 -0700
Re: Stop writing Python 4 incompatible code Chris Angelico <rosuav@gmail.com> - 2016-01-17 13:43 +1100
Re: Stop writing Python 4 incompatible code William Ray Wing <wrw@mac.com> - 2016-01-15 13:49 -0500
Re: Stop writing Python 4 incompatible code Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-01-15 16:53 -0200
Re: Stop writing Python 4 incompatible code Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-01-15 20:58 +0000
Re: Stop writing Python 4 incompatible code Christopher Reimer <christopher_reimer@icloud.com> - 2016-01-15 14:09 -0800
Re: Stop writing Python 4 incompatible code Christopher Reimer <christopher_reimer@icloud.com> - 2016-01-16 20:51 -0800
Re: Stop writing Python 4 incompatible code Chris Angelico <rosuav@gmail.com> - 2016-01-14 03:38 +1100
Re: Stop writing Python 4 incompatible code Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-01-14 10:38 +1300
Re: Stop writing Python 4 incompatible code Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-01-13 19:46 -0200
Re: Stop writing Python 4 incompatible code BartC <bc@freeuk.com> - 2016-01-14 01:02 +0000
Re: Stop writing Python 4 incompatible code Chris Angelico <rosuav@gmail.com> - 2016-01-14 12:21 +1100
Re: Stop writing Python 4 incompatible code BartC <bc@freeuk.com> - 2016-01-14 01:49 +0000
Page 4 of 4 — ← Prev page 1 2 3 [4]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2016-01-14 03:38 +1100 |
| Message-ID | <mailman.111.1452703135.13488.python-list@python.org> |
| In reply to | #101618 |
On Thu, Jan 14, 2016 at 3:25 AM, Random832 <random832@fastmail.com> wrote: > On Wed, Jan 13, 2016, at 09:21, sjmsoft@gmail.com wrote: >> This strikes me as very good advice. Thanks for being so far-sighted. >> And let's hope that Python 4 has fewer incompatibilities (none would >> good) than Python 3! > > Who says there's going to be a Python 4? I always assumed 3.9 would be > followed by 3.10. There most likely will be a Python 4.0 at some point. One theory is that 3.9 will be followed by 4.0, which will technically have some backward-incompatible changes (hence it would be inappropriate to call it 3.10), but in practical terms, good Py3.9 code will be identical to good Py4.0 code - it'll just remove things that got deprecated during the 3.x lifecycle. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Gregory Ewing <greg.ewing@canterbury.ac.nz> |
|---|---|
| Date | 2016-01-14 10:38 +1300 |
| Message-ID | <dfnufhF9cgdU1@mid.individual.net> |
| In reply to | #101592 |
Steven D'Aprano wrote: > Quote: > > if six.PY2: > # Python 2 code > elif six.PY3: > # Python 3 code > > In this case, no code will get executed on Python 4 at all! Which is good, because if no code is executed, it can't exhibit any bugs. Everyone should write their code this way, and then Python 4 will make *all* bugs in *all* programs disappear! -- Greg
[toc] | [prev] | [next] | [standalone]
| From | Bernardo Sulzbach <mafagafogigante@gmail.com> |
|---|---|
| Date | 2016-01-13 19:46 -0200 |
| Message-ID | <mailman.116.1452721626.13488.python-list@python.org> |
| In reply to | #101636 |
On Wed, Jan 13, 2016 at 7:38 PM, Gregory Ewing <greg.ewing@canterbury.ac.nz> wrote: > Steven D'Aprano wrote: >> >> Quote: >> >> if six.PY2: >> # Python 2 code >> elif six.PY3: >> # Python 3 code >> >> In this case, no code will get executed on Python 4 at all! > > > Which is good, because if no code is executed, it can't exhibit > any bugs. > > Everyone should write their code this way, and then Python 4 > will make *all* bugs in *all* programs disappear! > And if that is not enough, imagine how faster all tasks will finish. -- Bernardo Sulzbach
[toc] | [prev] | [next] | [standalone]
| From | BartC <bc@freeuk.com> |
|---|---|
| Date | 2016-01-14 01:02 +0000 |
| Message-ID | <n76rtg$rsd$1@dont-email.me> |
| In reply to | #101592 |
On 13/01/2016 07:30, Steven D'Aprano wrote: > Quote: > > With the end of support for Python 2 on the horizon (in 2020), > many package developers have made their packages compatible > with both Python 2 and Python 3 by using constructs such as: > > if sys.version_info[0] == 2: > # Python 2 code > else: > # Python 3 code > Better still, don't do version checks *at all*. There is almost never any > need for a version check. Better is to use feature detection: > > > try: > xrange # Succeeds in Python 2. > except NameError: > xrange = range I was surprised recently by just how much incompatibility there was between Python 2 and 3. It wasn't just about print with parentheses and range instead of xrange. I wanted to try out a jpeg decoder with PyPy and the three different ones I could find only worked with 2.x. Attempts to fix the incompatibilities usually lead to deeper mire. In the end it was easier to put together my own version, which ran on all Pythons (2.7 to 3.4). It was surprisingly easy to do; no need for conditional version code. (It was also smaller and considerably faster than the others even before I went tried PyPy. Using range in 2.7 instead of xrange didn't make much difference either.) -- Bartc
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2016-01-14 12:21 +1100 |
| Message-ID | <mailman.124.1452734486.13488.python-list@python.org> |
| In reply to | #101652 |
On Thu, Jan 14, 2016 at 12:02 PM, BartC <bc@freeuk.com> wrote: > I was surprised recently by just how much incompatibility there was between > Python 2 and 3. It wasn't just about print with parentheses and range > instead of xrange. > > I wanted to try out a jpeg decoder with PyPy and the three different ones I > could find only worked with 2.x. Attempts to fix the incompatibilities > usually lead to deeper mire. This implies that there are many differences between 2.x and 3.x. > In the end it was easier to put together my own version, which ran on all > Pythons (2.7 to 3.4). It was surprisingly easy to do; no need for > conditional version code. But this implies that the differences are pretty simple. Which argument are you putting? The biggest difference between 2.x and 3.x is the handling of text vs bytes. This is a very important distinction, but for a lot of programs, it's not difficult; most of what you'll be using will be text, and the only difference is that the 3.x version of your program can handle all of Unicode. If you open any files, you might need to specify encoding="utf-8" or encoding="ascii" or something, but that's about the only issue. > (It was also smaller and considerably faster than the others even before I > went tried PyPy. Using range in 2.7 instead of xrange didn't make much > difference either.) Yeah, the effectiveness of xrange over range isn't significant on smallish lists. And PyPy can optimize all sorts of things. If I'm writing 2/3 compatible code, I'll usually just use range() everywhere, unless I know for sure that the lists are going to be huge. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | BartC <bc@freeuk.com> |
|---|---|
| Date | 2016-01-14 01:49 +0000 |
| Message-ID | <n76umt$36k$1@dont-email.me> |
| In reply to | #101655 |
On 14/01/2016 01:21, Chris Angelico wrote: > On Thu, Jan 14, 2016 at 12:02 PM, BartC <bc@freeuk.com> wrote: >> I was surprised recently by just how much incompatibility there was between >> Python 2 and 3. It wasn't just about print with parentheses and range >> instead of xrange. >> >> I wanted to try out a jpeg decoder with PyPy and the three different ones I >> could find only worked with 2.x. Attempts to fix the incompatibilities >> usually lead to deeper mire. > > This implies that there are many differences between 2.x and 3.x. > >> In the end it was easier to put together my own version, which ran on all >> Pythons (2.7 to 3.4). It was surprisingly easy to do; no need for >> conditional version code. > > But this implies that the differences are pretty simple. Which > argument are you putting? That they are plenty of differences but I was adept at avoiding them! They didn't come up in my 700-line module anyway, except for the use of 'bytearray' which required upgrading from 2.5 to 2.7. (I needws to make use of bytearrays otherwise it could run out of memory on large inputs.) -- Bartc
[toc] | [prev] | [standalone]
Page 4 of 4 — ← Prev page 1 2 3 [4]
Back to top | Article view | comp.lang.python
csiph-web