'os.read(0,) vs sys.stdin.buffer.read() in python

I encountered the picotui library, and was curious to know a bit how it works.

I saw here (line 147) that it uses:

os.read(0,32)

According to Google 0 represents stdin, but also that the accepted answer for reading from stdin is via

sys.stdin.buffer.read()

I was wondering what the difference is between the two. Which is faster? Which is the more portable version?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source