Hi Crhis,

Have you tried just generating the docstrings at decoration time and
> applying them? By the sound of it, they won't change after that, and
> the only reason to run it later is performance... but have you
> actually measured a performance hit resulting from that?


I did. On my laptop (Intel i7-4700MQ), it takes about 4-12 milliseconds to
parse and reformat a single condition lambda function of a contract. This
quickly adds up to a couple of seconds if you have thousands of condition
functions to parse. This might not be a problem for a limited code base,
but I imagine that it could get inefficient very quickly as soon as the
contract usage would spread to the dependencies as well. Not dead-slow
inefficient, but inefficient enough to consider whether the automatic doc
generation is worth it.

Cheers,
Marko


On Sun, 7 Oct 2018 at 16:46, Chris Angelico <ros...@gmail.com> wrote:

> On Mon, Oct 8, 2018 at 1:41 AM Marko Ristin-Kaufmann
> <marko.ris...@gmail.com> wrote:
> > (If you wonder about the use case: I'd like to dynamically generate the
> docstrings when functions are decorated with contracts from icontract
> library. Condition functions need to be parsed and re-formatted, so this is
> something that should be done on-demand, when the user either wants to see
> the help() or when the sphinx documentation is automatically generated. The
> docs should not inflict computational overhead during the decoration since
> normal course of program operation does not need pretty-printed contracts.)
> >
>
> Have you tried just generating the docstrings at decoration time and
> applying them? By the sound of it, they won't change after that, and
> the only reason to run it later is performance... but have you
> actually measured a performance hit resulting from that?
>
> ChrisA
> _______________________________________________
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to