Re: Shall I worry about python2/3 compatibility when using library?

2018-08-31 Thread Grant Edwards
On 2018-08-31, Terry Reedy wrote: > That said, some people will continue to use existing python 2 code for a > decade or more. People like me. I do a lot of serial and network protocol handling in Python, and the changes to the handling of bytes vs. strings in Python 3 means that sort of thing

Re: Shall I worry about python2/3 compatibility when using library?

2018-08-31 Thread Mark Lawrence
On 31/08/18 06:33, Stone Zhong wrote: On Thursday, August 30, 2018 at 10:19:34 PM UTC-7, Terry Reedy wrote: On 8/30/2018 10:27 PM, Stone Zhong wrote: Hi there, I think the fact is: - There are still considerable amount of people still using python2 - Python2 user will eventually upgrade to pyt

Re: Shall I worry about python2/3 compatibility when using library?

2018-08-31 Thread Thomas Jollans
On 31/08/18 04:27, Stone Zhong wrote: Hi there, I think the fact is: - There are still considerable amount of people still using python2 - Python2 user will eventually upgrade to python3 So any library not written in a compatible way will either break now for python2 user, or will break in the

Re: Shall I worry about python2/3 compatibility when using library?

2018-08-30 Thread Chris Angelico
On Fri, Aug 31, 2018 at 3:50 PM, Cameron Simpson wrote: > And aim for Python 2.7 - this goes a long way to making 2 and 3 easy to work > with. The fursther back you go in 2.x the harder it gets. Yep; also, aim for 3.5+, since you get the ability to write u"..." (from 3.3) and b"..."%... (from 3.5

Re: Shall I worry about python2/3 compatibility when using library?

2018-08-30 Thread Cameron Simpson
On 30Aug2018 19:27, Stone Zhong wrote: I think the fact is: - There are still considerable amount of people still using python2 - Python2 user will eventually upgrade to python3 So any library not written in a compatible way will either break now for python2 user, or will break in the future f

Re: Shall I worry about python2/3 compatibility when using library?

2018-08-30 Thread Stone Zhong
On Thursday, August 30, 2018 at 10:19:34 PM UTC-7, Terry Reedy wrote: > On 8/30/2018 10:27 PM, Stone Zhong wrote: > > Hi there, > > > > I think the fact is: > > - There are still considerable amount of people still using python2 > > - Python2 user will eventually upgrade to python3 > > > > So any

Re: Shall I worry about python2/3 compatibility when using library?

2018-08-30 Thread Terry Reedy
On 8/30/2018 10:27 PM, Stone Zhong wrote: Hi there, I think the fact is: - There are still considerable amount of people still using python2 - Python2 user will eventually upgrade to python3 So any library not written in a compatible way will either break now for python2 user, or will break in

Shall I worry about python2/3 compatibility when using library?

2018-08-30 Thread Stone Zhong
Hi there, I think the fact is: - There are still considerable amount of people still using python2 - Python2 user will eventually upgrade to python3 So any library not written in a compatible way will either break now for python2 user, or will break in the future for python3 user. So I suppose a

Packaging for python2/3 compatibility

2018-08-12 Thread Gal Zaidman
_compiling and that is basically a package name starts with python2/3-*package-name*. But in RHEL or Centos, we have some packages named: python-*package-name*, *package-name*-python and so on, one example is libselinux, which in Fedora is: python2/3-libselinux and on Centos\RHEL is libselinux-pyth

Re: range() vs xrange() Python2|3 issues for performance

2011-08-04 Thread Steven D'Aprano
Chris Angelico wrote: > On Thu, Aug 4, 2011 at 4:01 AM, Steven D'Aprano > wrote: >> a, b = divmod(n, i) >> if b == 0: >> total += a+i >> > > Wouldn't this fail on squares? It happens to give correct results as > far as I've checked; no square up to 10,000 is called perfect, and > there are no pe

Re: range() vs xrange() Python2|3 issues for performance

2011-08-04 Thread Chris Angelico
On Thu, Aug 4, 2011 at 4:01 AM, Steven D'Aprano wrote: >        a, b = divmod(n, i) >        if b == 0: >            total += a+i > Wouldn't this fail on squares? It happens to give correct results as far as I've checked; no square up to 10,000 is called perfect, and there are no perfect squares

Re: range() vs xrange() Python2|3 issues for performance

2011-08-03 Thread Steven D'Aprano
harrismh777 wrote: > def perf(n): > sum = 0 > for i in range(1, n): > if n % i == 0: > sum += i > return sum == n A more effective way to speed that up is with a better algorithm: def isperfect(n): if n < 2: return False total = 1 for i in range(

Re: range() vs xrange() Python2|3 issues for performance

2011-08-02 Thread Chris Angelico
On Tue, Aug 2, 2011 at 3:45 PM, Steven D'Aprano wrote: > (But don't make the mistake of doing what I did, which was to attempt to > produce range(29000) in Python 2. After multiple *hours* of swapping, I > was finally able to kill the Python process and get control of my PC again. > Sigh.) >

Re: range() vs xrange() Python2|3 issues for performance

2011-08-02 Thread Steven D'Aprano
harrismh777 wrote: > The following is intended as a helpful small extension to the xrange() > range() discussion brought up this past weekend by Billy Mays... > > With Python2 you basically have two ways to get a range of numbers: > range() , which returns a list, and >xrange() , which r

Re: range() vs xrange() Python2|3 issues for performance

2011-08-02 Thread Chris Angelico
On Tue, Aug 2, 2011 at 10:05 AM, Peter Otten <__pete...@web.de> wrote: > i/2 returns a float in Python 3; you should use i//2 for consistency. > And I forgot to make this change before doing my tests. Redoing the Python 3 ones with // quite drastically changes things! 3.2 (r32:88445, Feb 20 2011,

Re: range() vs xrange() Python2|3 issues for performance

2011-08-02 Thread Chris Angelico
On Tue, Aug 2, 2011 at 10:20 AM, Stefan Behnel wrote: > What version of Py3 were you using? If you used the latest, maybe even the > latest hg version, you will notice that that's substantially faster for > integers than, e.g. 3.1.x. > I just tried this out, using a slightly modified script but t

Re: range() vs xrange() Python2|3 issues for performance

2011-08-02 Thread Thomas Rachel
Am 02.08.2011 09:12 schrieb harrismh777: The following is intended as a helpful small extension to the xrange() range() discussion brought up this past weekend by Billy Mays... With Python2 you basically have two ways to get a range of numbers: range() , which returns a list, and xrange() , whic

Re: range() vs xrange() Python2|3 issues for performance

2011-08-02 Thread Stefan Behnel
harrismh777, 02.08.2011 09:12: With Python2 you basically have two ways to get a range of numbers: range() , which returns a list, and xrange() , which returns an iterator. With Python3 you must use range(), which produces an iterator; while xrange() does not exist at all (at least not on 3.2).

Re: range() vs xrange() Python2|3 issues for performance

2011-08-02 Thread Peter Otten
harrismh777 wrote: > The following is intended as a helpful small extension to the xrange() > range() discussion brought up this past weekend by Billy Mays... > > With Python2 you basically have two ways to get a range of numbers: > range() , which returns a list, and >xrange() , which r

Re: range() vs xrange() Python2|3 issues for performance

2011-08-02 Thread garabik-news-2005-05
harrismh777 wrote: these will run on either Python2 or > Python3... except that if you substitute xrange() for range() for > Python2 they will throw an exception on Python3... doh. if 'xrange' not in dir(__builtins__): xrange = range at the beginning of your program will fix that. --

range() vs xrange() Python2|3 issues for performance

2011-08-02 Thread harrismh777
The following is intended as a helpful small extension to the xrange() range() discussion brought up this past weekend by Billy Mays... With Python2 you basically have two ways to get a range of numbers: range() , which returns a list, and xrange() , which returns an iterator. With Python

Re: python2+3

2011-05-19 Thread Steven D'Aprano
On Thu, 19 May 2011 05:42:29 -0700, lkcl wrote: > has anyone considered the idea of literally creating a Python2/ > subdirectory in the python3 codebase, literally just dropping the entire > python2.N code directly into it, renaming all functions and data > structures, adding a "--2-compatible" s

python2+3

2011-05-19 Thread lkcl
[changing subject, seems a good idea...] On May 19, 2:13 am, Terry Reedy wrote: > On 5/18/2011 9:42 AM, lkcl wrote: > > >   he's got a good point, terry.  breaking backwards-compatibility was a > > completely mad and incomprehensible decision. > > I see that I should take everything you (or Harri