This are some notes that I took while the talk that I saw today, the original title of the talk that I had the chance to see today was: “Switch to Python 3… Now… Inmediately” by the professor Russel Winder.
More or less all that you will find here is a transaction, just ordered in my style and perhaps with some notes by myself.
Python 2.x remains being the default python. Too many people and organizations are afraid of the change.
Python software foundation should declare python 3 the default python immediately.
2to3tool is not useful at all. Just one shot transform tool.
Python 2 is a dead end and python 3 is the developing future.
This piece of code is compatible with both versions, why don’t use them?
print(x) support multiple parameter in python 3, so, let’s
import the function from future to have the same behaviour in python
from __future__ import print_function
Let’s make it bigger:
from __future__ import ( division, absolute_import, print_function, unicode_literals )
With this we will avoid problems with floats on divisions, add . to the imports, import the python3 version of print and work always with unicode.
Another problem is the list-comprehensions which will change a little bit, instead create list, they will create sets.
python 2 is strict, but python 3 is kinda lazy.
map(lambda x: x * x, filter(lambda x: x % 10 == 0, range(100))
Will produce an iterator in python 3, in python 2 is a data structure.
This is one of the biggest issues into the migration, other functions
with same problems will be, for example:
itervalues which in python 3 will become:
If you want a data structure instead a iterator, you should make it manually:
range(10) # python 2.x tuple(range(10) # python 3
At least IronPython and Jython do not have a GIL as CPython and PyPy do.
There is an experiment to mode GIL out of PyPy.
Actors : communicate processes with messages.
Dataflow : operators connected by channels with activity triggered by arrival of data on the channels.
Transform a sequence to another sequence where all individual actions happen at the same time. Python has not a lot of utilities for that, since Go or D do.
concurrent.futures : python 3.2 package to abstract over threads and processes to give an asynchronous function call and future system.