Moving docstrings from C to Python
Hi, Travis recently advertised the add_docstring and add_newdoc functions, which are used to add documentation to functions written in C. This brings the advantage that you don't have to recompile everytime you change a docstrings, and also that the docstrings are much simpler to format (no more "\n\" tokens all over the place). I took all the docstrings from numpy.core.src.multiarray and formatted them to be used with add_docstring. I have two questions: Would anyone mind if the change was made? If not, where should they go? (numpy/add_newdocs.py or numpy/core/something) Thanks for the feedback. Stéfan
2006/7/28, Stefan van der Walt
Hi,
Travis recently advertised the add_docstring and add_newdoc functions, which are used to add documentation to functions written in C. This brings the advantage that you don't have to recompile everytime you change a docstrings, and also that the docstrings are much simpler to format (no more "\n\" tokens all over the place).
I took all the docstrings from numpy.core.src.multiarray and formatted them to be used with add_docstring. I have two questions:
Would anyone mind if the change was made?
I don't, I wanted to do the same thing. numpy/add_newdocs.py +1 David
On 7/28/06, Stefan van der Walt
Would anyone mind if the change was made? If not, where should they go? (numpy/add_newdocs.py or numpy/core/something)
Another +1 for numpy/add_newdocs.py and a suggestion: check for Py_OptimizeFlag > 1 in add_newdoc so that docstrings are not loaded if python is invoked with -OO option. This will improve import numpy time and reduce the memory footprint. I'll make the change if no one objects.
I started to do the same with array methods, but before I spend too much
time on it, I'd like to be sure I'm doing the right thing.
1. In add_newdocs.py, add
from numpy.core import ndarray
2. then add an entry for each method, eg
add_docstring(ndarray.var,
"""a.var(axis=None, dtype=None)
Return the variance, a measure of the spread of a distribution.
The variance is the average of the squared deviations from the mean,
i.e. var = mean((x - x.mean())**2).
See also: std
""")
3. in arraymethods.c,
delete static char doc_var[] = ...
remove doc_var in
{"var", (PyCFunction)array_variance,
METH_VARARGS|METH_KEYWORDS, doc_var},
David
2006/7/28, Sasha
On 7/28/06, Stefan van der Walt
wrote: Would anyone mind if the change was made? If not, where should they go? (numpy/add_newdocs.py or numpy/core/something)
Another +1 for numpy/add_newdocs.py and a suggestion: check for Py_OptimizeFlag > 1 in add_newdoc so that docstrings are not loaded if python is invoked with -OO option. This will improve import numpy time and reduce the memory footprint. I'll make the change if no one objects.
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
participants (3)
-
David Huard
-
Sasha
-
Stefan van der Walt