Kappa-Dev / KappaTools

Tool suite for kappa models. Documentation and binaries can be found in the release section. Try it online at
http://kappalanguage.org/
GNU Lesser General Public License v3.0
113 stars 41 forks source link

Fixing inefficiency in Kappa IO with kappy #596

Closed yarden closed 5 years ago

yarden commented 5 years ago

The main purpose of this pull request is to fix an inefficiency in the IO between Python programs and Kappa agents. The problem before was that the output from Kappa processes was read one character at a time, which is extremely inefficient. My fix instead reads the output in chunks (using the default buffer size as set by Python module io). The key function that fixes the problem is read_stdout (https://github.com/yarden/KaSim/blob/master/python/kappy/kappa_std.py#L97).

Please proceed with caution as I haven't tested this extensively and kappy doesn't yet have a unit testing suite. But I am pretty certain that the character by character reading was the source of the inefficiency and that simply reading the output in larger chunks dramatically speeds things up.

pirbo commented 5 years ago

Thank you so much for sorting that out! I pushed 4ca2b481fc11bbb5d119ed69b22ba85a48807904 into master.