Hi All,

Thanks for sending along this post, and please allow me the opportunity to 
weigh in on teaching 3 vs. 2.

I've read a lot of responses to this have essentially said "Python 3 doesn't 
have any killer features that you can't get in Python 2". One of the biggest 
things that my team gets out of Python 3 is that iteration and generator 
functions are much, much better. In Python 3, Most container data types use 
iteration natively rather than instantiating and returning lists. For example 
dict.keys(), dict.values(), and dict.items() all return *iterators* and 
memoryviews rather than lists or tuples.

https://www.python.org/dev/peps/pep-3106/

Same with the range() builtin and a lot of others. This doesn't fundamentally 
change the way that the code reads (so may be a bit opaque to the user), but 
can have a large impact on how the code executes for large sets of input. In 
the earth sciences (I work in climate science) this is a big deal, because your 
input size can be huge. Most of the time, our computations are limited by the 
RAM on the system, so not having make copies of your data on the stack (R is 
notorious for this) can potentially give you a multiplicative increase in 
throughput.

Generators are substantiall easier to use with the addition of the "yield from 
[some iterator]" statement. It basically allows you to build up sets of 
generators and then mix and match them.

https://docs.python.org/3.3/whatsnew/3.3.html#pep-380-syntax-for-delegating-to-a-subgenerator

Python iterators and generators can be more advanced topics that we won't 
necessarily be teaching beginners. However, they are definitely something that 
allows you to scale up your code to larger input data sets, so they're 
something that scientists will want when they work up to using them. And the 
support in Python 3 is much better and more consistent.

Glad to hear that the workshops that have used Python 3 have been smooth.

~James

On Mon, Jun 15, 2015 at 04:37:11PM -0700, Steven Haddock wrote:
> This was a timely post by Maxime, because I was just thinking of surveying 
> instructors about what they use for their own work and what were the thoughts 
> about porting SWC lessons to Python 3. I can’t remember if there was a recent 
> thread on this…
> Worth creating an issue (or something even more formal) and having people 
> state their cases? 
> 
> We are using Python 3 for the next edition of our book, but I feel a bit like 
> the first guy over the wall at the Battle of Hastings, looking over my 
> shoulder at the other 85% huddled in relative safety
> .
> -Steve
> 
> 
> > On Jun 15, 2015, at 12:17 , Maxime Boissonneault 
> > <[email protected]> wrote:
> > 
> > Some interresting reading :
> > 
> > http://astrofrog.github.io/blog/2015/05/09/2015-survey-results/
> > 
> > Maxime

-- 
James Hiebert
Lead, Computational Support
Pacific Climate Impacts Consortium
http://www.pacificclimate.org
E-mail: [email protected]

_______________________________________________
Discuss mailing list
[email protected]
http://lists.software-carpentry.org/mailman/listinfo/discuss_lists.software-carpentry.org

Reply via email to