<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi Crhis,<br><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Have you tried just generating the docstrings at decoration time and<br>
applying them? By the sound of it, they won't change after that, and<br>
the only reason to run it later is performance... but have you<br>
actually measured a performance hit resulting from that?</blockquote><br></div>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.<br><br></div><div>Cheers,<br></div><div>Marko<br></div><div dir="ltr"><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, 7 Oct 2018 at 16:46, Chris Angelico <<a href="mailto:rosuav@gmail.com">rosuav@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, Oct 8, 2018 at 1:41 AM Marko Ristin-Kaufmann<br>
<<a href="mailto:marko.ristin@gmail.com" target="_blank">marko.ristin@gmail.com</a>> wrote:<br>
> (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.)<br>
><br>
<br>
Have you tried just generating the docstrings at decoration time and<br>
applying them? By the sound of it, they won't change after that, and<br>
the only reason to run it later is performance... but have you<br>
actually measured a performance hit resulting from that?<br>
<br>
ChrisA<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div>