Skip to content
sasdf edited this page Oct 31, 2018 · 2 revisions

Naming for exposed api

In order to be easy to type, use all lowercase if it won't hurt readability (e.g. readuntil), otherwise use camelCase.

Property vs Method

If a method is pure and takes no extra argument (e.g. len), it should be a property.

However, type conversion may not be pure. It depends on the source type (e.g. list or generator).

For the consistency, all type conversion method which take no extra argument should be properties.

Size parameter in Unified I/O

Python's file has a size hint parameter in some method, like readline. Hitting such size limit indicates a mismatched protocol. For example, if we run readline(2) for input aabb\n, the remaining bb\n would be unexpected in next read. We should raise an error instead of truncate, so we decided to remove such parameter in our wrapper.

For the same reason, our read (alias of exactly or readexactly) method will return a string/bytes with exactly the given size.

If you know nothing about the size and the delimiter, use some (alias of readsome) to get all currently available data.

In order to avoid the resource being exhausted, the underlying buffer will raise an OverflowError when it grows too large.

Clone this wiki locally