[Biopython-dev] Bio._utils iterlen not needed
Peter Cock
p.j.a.cock at googlemail.com
Thu Jan 10 13:03:50 UTC 2013
On Thu, Jan 10, 2013 at 9:21 AM, Michiel de Hoon <mjldehoon at yahoo.com> wrote:
>
> Dear all,
>
> As far as I can tell the iterlen function in Bio._utils is not needed.
> Simply calling len(items) does exactly what iterlen does, and is much faster too.
No, the reason d'être for iterlen is that you can't use len on an iterator, e.g.
>>> len(iter("abcde"))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: object of type 'iterator' has no len()
>>> from Bio._utils import iterlen
>>> iterlen(iter("abcde"))
5
Perhaps the function needs a little more documentation...
> For the other functions, are they important enough to warrant
> a separate module? From our previous experience in Biopython,
> these kinds of utility modules tend to be underused. This is
> because the functions are simple and therefore easy to
> replicate, and often they do not do exactly what is needed
> in a particular module. Similar utility modules in Biopython
> in the past were forgotten after a while, and then deprecated
> and removed.
Note that Bio._utils has a leading underscore - these are
therefore a 'private' API which we don't have to worry about
maintaining and deprecated etc in the same way as a public
API. We're not expect end users to use this module ;)
The functions here were originally helper functions used in
Bio.Phylo which are now also used in Bio.SearchIO - I think
a shared private module like this is a good compromise
between code duplication and top level modules.
Peter
More information about the Biopython-dev
mailing list