[cctbxbb] cctbx.python unnecessarily unfriendly

Nathaniel Echols nechols at lbl.gov
Wed Jan 8 13:18:17 PST 2014


On Wed, Jan 8, 2014 at 12:51 PM, James Stroud <xtald00d at gmail.com> wrote:

> Here, the “-Qnew” flag forces the python interpreter to work with new
> division (where “/“ does not strictly mean integer division).
>
> This flag basically overrides the expected python behavior to which python
> programmers have been writing code for over a decade, wrecks some
> dependencies, and stifles new code that itself depends on cctbx.
>
> It is highly frustrating to work around this highly unnecessary flag!!
>
> Fortunately, python has a better way to handle this problem by just having
> “from __future__ import division” at the top of .py files. In fact, I have
> spot-checked several files in the cctbx source tree and noticed that the
> ALL have this line at the top.
>
> So why does the -Qnew flag still exist in the cctbx.python script? It is
> entirely unnecessary and requires any and all dependencies to be programmed
> to a behavior that is not standard for the language.
>

There are basically two reasons for this:

1) The old behavior is, in our opinion, fundamentally broken (and Python 3
completely discards it).  (We didn't realize how many other packages were
accidentally dependent on it until much later.)

2) Many of the development choices involving CCTBX are made based on the
requirements of Phenix.  Unfortunately, whereas Ralf was very militant
about enforcing certain development rules for CCTBX code (as we continue to
be), it has been nearly impossible to get the other Phenix developers to
follow the same (or any!) rules.  ("Cat herding" doesn't even begin to
describe it.)  Adding -Qnew was the easiest way to ensure that all of the
code in Phenix had similar behavior with respect to division.

I agree that this creates problems for third-party packages.  It would
certainly be safer and more intuitive if we could avoid it altogether; I
will discuss this with the other developers.  Since it is somewhat
non-trivial at the moment to fix the rest of Phenix to have the desired
behavior, and I'm trying to revise a paper among other things, I'm
deferring this until some point when I have time and free brain cells
(possibly until our next Phenix meeting in mid-March).  For now, I've
modified libtbx/env_config.py so you can do this:

/usr/bin/python /path/to/libtbx/configure.py --old_division cctbx

which will give you cleaner dispatchers.  I'm pretty sure the rest of CCTBX
should still behave sensibly, since we're pretty militant about including
the __future__ statement in these files.  Is that sufficiently usable for
the short term?

-Nat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://phenix-online.org/pipermail/cctbxbb/attachments/20140108/70471e04/attachment.htm>


More information about the cctbxbb mailing list