[Biopython-dev] PATCH: NumPy support for BioPython

Ed Schofield edschofield at gmail.com
Sat Mar 10 10:40:55 UTC 2007

On 3/10/07, Michiel Jan Laurens de Hoon <mdehoon at c2b2.columbia.edu> wrote:
> Ed Schofield wrote:
> > On 3/9/07, Michiel Jan Laurens de Hoon <mdehoon at c2b2.columbia.edu>
> wrote:
> >> So, if we use this macro instead of CONTIGUOUS directly, we can avoid
> >> using oldnumeric.h. Or am I missing something?
> >
> > Yeah, sure, but why would we want to avoid using oldnumeric.h?
> Why #include oldnumeric.h if we don't need it? The fewer changes we need
> to make to Biopython and the cleaner we can keep the code, the better. I
> see no justification for #including an unnecessary header file.

It's a minor issue, but I can see several reasons to use the header file
NumPy provides for the purpose, rather than pasting its definitions into our
own source files:
- because, by isolating the NumPy definitions from the BioPython source
files, it leads to code that's shorter overall and (IMHO) simpler
- because we may have C extensions in the future that need other parts of
the compatibility interface
- because any future bugfixes or changes to NumPy's oldnumeric.h would then
be picked up automatically

Would we write helloworld.c like this?

int  printf(const char * __restrict, ...) __DARWIN_LDBL_COMPAT(printf);
int main()
    printf("Hello, world!\n");


I can understand if you're wanting to make an early start on the porting
process to remove the dependence on the oldnumeric compatibility layer
entirely. But in this case I don't think it's worth it; a full port to
NumPy's native interfaces would break Numeric compatibility, which you're
committed to keeping for some time yet. The oldnumeric interface won't be a
hindrance for BioPython's users anyway -- with my patch they can either use
Numeric or uninstall it entirely and instead pass native NumPy arrays
between BioPython and other packages like SciPy, Matplotlib and PyTables.

-- Ed

More information about the Biopython-dev mailing list