sphinx-contrib / matlabdomain

A Sphinx extension for documenting Matlab code
http://sphinxcontrib-matlabdomain.readthedocs.io/
Other
70 stars 45 forks source link

speed up reading MATLAB source #23

Closed joeced closed 6 years ago

joeced commented 10 years ago

Originally reported by: Mark Mikofski (Bitbucket: bwanamarko, GitHub: Unknown)


Currently only modules are cached in sys.modules, but classdefs are not.

The way Documenter imports objects is by importing the module, then walks its namespace calling the getter method for each path. EG: for pkg.mod.cls.attr it would import pkg then use pkg.getter('mod') to get mod, etc. If a class is encountered it is lexed using Pygments.

This means that a class might be lexed multiple times which is time consuming.

  1. profile a build to see where bottlenecks are
  2. in matlabify, check if modname is in sys.modules before calling MatModule
  3. after a class or function is firts parsed, attach it to it's MatModule using setattr() which is already in sys.modules so that it can be called using getattr()
  4. in MatModules getter method, check if the class or function is an attr using hasattr(), then don't reparse but just return the already parsed object.

joeced commented 6 years ago

Original comment by Mark Mikofski (Bitbucket: bwanamarko, GitHub: Unknown):


fixes #18 speed up reading parsing files

joeced commented 10 years ago

Original comment by Mark Mikofski (Bitbucket: bwanamarko, GitHub: Unknown):


fixes #18 speed up reading parsing files