[Biopython-dev] Python 2 and 3 migration thoughts

Eric Talevich eric.talevich at gmail.com
Tue Oct 22 16:35:25 UTC 2013


On Tue, Oct 22, 2013 at 6:59 AM, Peter Cock <p.j.a.cock at googlemail.com>wrote:

> On Sun, Oct 20, 2013 at 3:32 PM, Peter Cock wrote:
> > Hi all,
> >
> > I've just made a pull request on dictionary method handling:
> > https://github.com/biopython/biopython/pull/248
> >
> > Some comments over on GitHub (or here) would be great.
> >
> > Thanks,
> >
> > Peter
>
> Thanks for looking over that Eric, if there are no objections
> I intend to rebase and apply the dictionary changes later this
> week: https://github.com/biopython/biopython/pull/248
>
> Separately, regarding the imports issue - do people have
> a preference on the try/except as demonstrated here
> https://github.com/biopython/biopython/pull/249 versus
> a compatibility layer in Bio._py3k, or a bundled copy of
> 'six'?
>
> e.g. https://github.com/peterjc/biopython/tree/builtins
> e.g. https://github.com/peterjc/biopython/tree/six
>
> Thanks,
>
> Peter
>

I just looked at the source code for six:
https://bitbucket.org/gutworth/six/src/db5564076aa8/six.py?at=default

It's very compact, much shorter than I expected but also quite dense. I get
the sense they've had enough eyes on the codebase to sort out performance
issues and edge cases, e.g. sys.MAXSIZE on Jython.

For docstrings, I agree that directly showing the try/except block is more
informative for users on either genus of Python. For the rest of the
codebase, I would favor using a bundled copy of six (e.g. Bio._six). The
benefits are (a) not having to discover and fix all the subtle bugs
ourselves, (b) to be explicit about where we've done something for Py2/3
compatibility and not as an essential part of the way the code is supposed
to work, and (c) six has its own documentation.

I also see some virtue in not relying on six/Bio._py3k where it's not
necessary, since six is compatible back to Python 2.4 and we only go back
to Python 2.6 now. Halfway approach: just look at six and copy only the
bits we need into _py3k?

-Eric



More information about the Biopython-dev mailing list