I was using python-future for a while until profiling revealed that my program's 50 million instantiations of newint
was increasing the runtime of my program 10-fold. I have the thing running fine in Python 3, but trying to make it compatible with 2 and 3 is highly desired as I'm kind of alone in my organization as the sole Py3 pusher.
future
has some nice documentation that says to throw
from __future__ import (absolute_import, division,
print_function, unicode_literals)
from future.builtins import *
up as a boilerplate in all my source files then code in standard 3. However, because it seems to be ever-so-slightly heavy, when parsing lots of text files it's a drag.
six
seems to be much more lightweight, but what's the usual way to use it? The documentation is a bit flat and easy to gloss over... I currently have something like:
from __future__ import (
absolute_import, division, print_function, unicode_literals)
import six
from six.moves import (zip, filter, map, range, reduce, input)
There's something about lazily loading modules on attribute-access however; can I just say from six.moves import *
, or will it actually load all the HTTP, Tkinter, etc. jazz then and there? What are the "best practices" for developing Py2+3 code with six
?