Ask for clarifying support for python 2

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
mlampert
Posts: 1463
Joined: Fri Sep 16, 2016 9:28 pm

Ask for clarifying support for python 2

Postby mlampert » Sun Apr 28, 2019 5:39 am

For 0.19 development, can we ignore python 2 compatibility ?
And can I start removing the constructs to support both (for Path)?
wmayer
Site Admin
Posts: 15724
Joined: Thu Feb 19, 2009 10:32 am

Re: Ask for clarifying support for python 2

Postby wmayer » Sun Apr 28, 2019 8:27 am

With v0.19 the default is Py3 now and for me it's OK to ignore Py2 in new code.

For existing code it might be helpful to keep Py2-related code because I don't think that we are already 100% Py3-compliant and in cases where Py3 fails it's useful to see how the correct behaviour is with Py2.
vocx
Posts: 4000
Joined: Thu Oct 18, 2018 9:18 pm

Re: Ask for clarifying support for python 2

Postby vocx » Sun Apr 28, 2019 8:30 am

mlampert wrote:
Sun Apr 28, 2019 5:39 am
For 0.19 development, can we ignore python 2 compatibility ?
And can I start removing the constructs to support both (for Path)?
What type of constructs are these? Does it matter that much? Or is it just a question of removing one or two extra lines (if Python 2...).

My personal opinion is that there is no need to remove anything. I mean, I certainly wouldn't add new Python 2 support, but leaving the old code doesn't really hurt, or does it? The file size may become insignificantly smaller, but that's about it.

If your intention is to really break things for old users and force them to use Python 3, then go ahead, but I don't think that's exactly right. Or do you plan on using Python 3 features that really improve execution of the code? Then it would make sense, but only if the improvement is really noticeable, otherwise, why bother with premature optimization?

I know Python 2's end of life is 2020, but I personally wouldn't remove any old code until it is well after that, say, 2025. Remember that end of life doesn't mean the Python 2 interpreter ceases to exist, it just means the Python Foundation won't provide any more patches. There will be computers running Python 2 environments forever, as long as they turn on.
Always add the important information to your posts if you need help.
To support the documentation effort, and code development, your donation is appreciated: paypal.
chrisb
Posts: 24293
Joined: Tue Mar 17, 2015 9:14 am

Re: Ask for clarifying support for python 2

Postby chrisb » Sun Apr 28, 2019 11:45 am

Keeping the code as clean as possible supports maintainability. An extra conditional here, some different function calls there ... Why should they be kept? It's one of the bad smells in a program, which is not nessecarily wrong, but should usually be avoided. People may want to keep their python2. I would guess that they are users who don't really want to have always the newest stuff. So they will probably be happy using 0.18.

Just as you are guessing about an anonymous crowd of users I am very sure that the number of people going for 0.19 with python2 is very close to zero.
User avatar
kkremitzki
Posts: 1986
Joined: Thu Mar 03, 2016 9:52 pm
Location: Texas

Re: Ask for clarifying support for python 2

Postby kkremitzki » Sun Apr 28, 2019 7:38 pm

I think removing Python 2 cruft from the codebase is a good 0.19 goal because we will almost surely be releasing after Python 2's end of life on January 1st 2020, but we might be a little too early in the development cycle for it, since e.g. I haven't gotten the daily builds set up for 0.19 yet still.
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Ask for clarifying support for python 2

Postby NormandC » Mon Apr 29, 2019 4:33 am

Wouldn't it make sense to drop Python 2 from the freecad-daily builds (for 18.04+) as soon as possible, to have the most time to iron out Python 3 issues? Quite a few python developers have lamented on the forum in the past year that the daily builds were still based on Py2. In any case Python 2 is still available in the freecad-stable PPA as a fallback.