Becksteinlab / GromacsWrapper

GromacsWrapper wraps system calls to GROMACS tools into thin Python classes (GROMACS 4.6.5 - 2024 supported).
https://gromacswrapper.readthedocs.org
GNU General Public License v3.0
169 stars 53 forks source link

Improve loading times #75

Closed pslacerda closed 8 years ago

pslacerda commented 8 years ago

Importing GromacsWrapper take seconds. Most of time was wasted in extracting the help for docstrings. Seems that both running the help commands and communicating to acquire the text takes almost 90% of loading times.

This screenshot was taken while profiling the gromacs package importing:

callgraph

Albeit it is useful, isn't a such important feature and the library keeps running without it. Or maybe we can load it dynamically and make something similar to this:

class GromacsCommand(Command):
    @property
    def __doc__(self):
        if not self.__doc_cache:
            # load docstring
        return self.__doc_cache

Another option would be to reset GromacsCommand.__doc__ for each subclass. Now we can't simply set Trjconv.__doc__ = "docstring" because Command is an old style class (eg class C(object): pass) which disallow change members of object (ie __doc__). This change would allow it:

# doesn't inherit from object
class Command:
    pass
orbeckst commented 8 years ago

I like the idea of loading the doc strings lazily!

pslacerda commented 8 years ago

Done =)