{"action":"created","issue":{"url":"https://api.github.com/repos/pexpect/ptyprocess/issues/3","repository_url":"https://api.github.com/repos/pexpect/ptyprocess","labels_url":"https://api.github.com/repos/pexpect/ptyprocess/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/pexpect/ptyprocess/issues/3/comments","events_url":"https://api.github.com/repos/pexpect/ptyprocess/issues/3/events","html_url":"https://github.com/pexpect/ptyprocess/issues/3","id":46159836,"number":3,"title":"Potential performance issue with unbuffered IO and the PtyProcess readline method","user":{"login":"anwilli5","id":1797109,"avatar_url":"https://avatars.githubusercontent.com/u/1797109?v=3","gravatar_id":"","url":"https://api.github.com/users/anwilli5","html_url":"https://github.com/anwilli5","followers_url":"https://api.github.com/users/anwilli5/followers","following_url":"https://api.github.com/users/anwilli5/following{/other_user}","gists_url":"https://api.github.com/users/anwilli5/gists{/gist_id}","starred_url":"https://api.github.com/users/anwilli5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anwilli5/subscriptions","organizations_url":"https://api.github.com/users/anwilli5/orgs","repos_url":"https://api.github.com/users/anwilli5/repos","events_url":"https://api.github.com/users/anwilli5/events{/privacy}","received_events_url":"https://api.github.com/users/anwilli5/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pexpect/ptyprocess/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/pexpect/ptyprocess/labels/help%20wanted","name":"help wanted","color":"159818"},{"url":"https://api.github.com/repos/pexpect/ptyprocess/labels/needs-tests","name":"needs-tests","color":"f7c6c7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2014-10-18T02:01:44Z","updated_at":"2016-02-11T22:54:42Z","closed_at":null,"body":"Calls to self.fileobj.readline() from the PtyProcess readline() method read data one byte at a time (most likely since fileobj is opened with 'buffering=0'.)  Thus, this program:\r\n\r\n```python\r\nfrom ptyprocess import PtyProcess, PtyProcessUnicode\r\np = PtyProcess.spawn(['perl',  '-e', '''use 5.010; foreach my $letter ('a'..'z'){ say $letter x 1000; }'''])\r\nwhile(1):\r\n    try:\r\n        print p.readline()\r\n    except EOFError:\r\n        break\r\np.close()\r\n```\r\n\r\nHas pretty poor performance (output from strace):\r\n\r\n```\r\n% time     seconds  usecs/call     calls    errors syscall\r\n------ ----------- ----------- --------- --------- ----------------\r\n 93.48    0.465020          18     26214         1 read\r\n  2.28    0.011353          23       489       381 open\r\n  0.84    0.004197        4197         1           clone\r\n  0.61    0.003037          19       160       113 stat\r\n```\r\n\r\nIs there a compelling reason to specify that the fileobj should have unbuffered IO?\r\n\r\nThe PtyProcess read() method does not experience this behavior because it uses a default buffer size of 1024."},"comment":{"url":"https://api.github.com/repos/pexpect/ptyprocess/issues/comments/183091949","html_url":"https://github.com/pexpect/ptyprocess/issues/3#issuecomment-183091949","issue_url":"https://api.github.com/repos/pexpect/ptyprocess/issues/3","id":183091949,"user":{"login":"jquast","id":972584,"avatar_url":"https://avatars.githubusercontent.com/u/972584?v=3","gravatar_id":"","url":"https://api.github.com/users/jquast","html_url":"https://github.com/jquast","followers_url":"https://api.github.com/users/jquast/followers","following_url":"https://api.github.com/users/jquast/following{/other_user}","gists_url":"https://api.github.com/users/jquast/gists{/gist_id}","starred_url":"https://api.github.com/users/jquast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jquast/subscriptions","organizations_url":"https://api.github.com/users/jquast/orgs","repos_url":"https://api.github.com/users/jquast/repos","events_url":"https://api.github.com/users/jquast/events{/privacy}","received_events_url":"https://api.github.com/users/jquast/received_events","type":"User","site_admin":false},"created_at":"2016-02-11T22:54:42Z","updated_at":"2016-02-11T22:54:42Z","body":"Sure! we have an extra long holiday weekend in the US, so I've got no excuse to be too busy :) I'll give it a thorough review no later than Monday.\n"}}