A "with" variant for use in expressions

In an ideal world, json.load() would stream the data in, rather than loading it all into memory then calling json.loads().

Unfortunately, looking at the source code, it appears this is not an ideal world. :disappointed_face:

This proposal seems preferable because it leaves the door open for alternative implementations of json.load()to handle reading the file differently. And, besides, I offered it as a simple example; in general there may not be such alternatives as Path.read_text().

1 Like