Menu

#179 Pyserial Write using python3 extremely slow

v2.7
open
nobody
None
1
2015-01-19
2015-01-16
No

I ported my Firmata client library to python3 https://github.com/MrYsLab/PyMata, and the pyserial write seems to be much a slower than when I run the code using python 2, Is this a known problem? I have not published the Python 2/3 compatibility files as of yet, but can easily provide them. I also have profiling files created with cProfile and pyprof2calltree if that would be of help.

Discussion

  • Alan Yorinks

    Alan Yorinks - 2015-01-16

    I forgot to mention that this is running on Ubuntu 14.10.

     
  • Alan Yorinks

    Alan Yorinks - 2015-01-16

    Additional information - I don't see the slowdown when running my code on Windows8.1, with Python 3.4.2, only on Linux.

     
  • Alan Yorinks

    Alan Yorinks - 2015-01-18

    Update - I added a call to nonblocking() (I test for linux first) and writeTimout = 0.
    This seems to fix the problem for Python 3.4 and does not seem to break anything for Python 2.7.

    I will be testing this week to see if the performance problems are truly solved with this technique, and if so, I will be closing this ticket.

     
  • Alan Yorinks

    Alan Yorinks - 2015-01-19

    Final update. I will be leaving this ticket open. It appears that Serial.write when executed in Python 3.4 is approximately 10% slower than when executed in Python 2.7. The Serial.write is spent in both the os level write and os level select. For Python 3 the amount of time being spent in select is huge compared to its Python 2 counterpart.

    I am attaching a spread sheet with the profiling data I created running my library. My tests consists of running one application that "polls", that is it continually writes, and one that uses a call back method that triggers the write.

    I would greatly appreciate your thoughts about whether this is an "incompatibility" between linux and Python 3, and/or if there is something that could be changed in the pyserial library to alleviate the problems.

     

Log in to post a comment.