
Hello, On Fri, 27 Jun 2014 12:08:41 +1000 Steven D'Aprano <steve@pearwood.info> wrote:
On Fri, Jun 27, 2014 at 03:07:46AM +0300, Paul Sokolovsky wrote:
With my MicroPython hat on, os.scandir() would make things only worse. With current interface, one can either have inefficient implementation (like CPython chose) or efficient implementation (like MicroPython chose) - all transparently. os.scandir() supposedly opens up efficient implementation for everyone, but at the price of bloating API and introducing heavy-weight objects to wrap info.
os.scandir is not part of the Python API, it is not a built-in function. It is part of the CPython standard library.
Ok, so standard library also has API, and that's the API being discussed.
That means (in my opinion) that there is an expectation that other Pythons should provide it, but not an absolute requirement. Especially for the os module, which by definition is platform-specific.
Yes, that's intuitive, but not strict and formal, so is subject to interpretations. As a developer working on alternative Python implementation, I'd like to have better understanding of what needs to be done to be a compliant implementation (in particular, because I need to pass that info down to the users). So, I was told that https://docs.python.org/3/reference/index.html describes Python, not CPython. Next step is figuring out whether https://docs.python.org/3/library/index.html describes Python or CPython, and if the latter, how to separate Python's stdlib essence from extended library CPython provides?
In my opinion that means you have four options:
1. provide os.scandir, with exactly the same semantics as on CPython;
2. provide os.scandir, but change its semantics to be more lightweight (e.g. return an ordinary tuple, as you already suggest);
3. don't provide os.scandir at all; or
4. do something different depending on whether the platform is Linux or an embedded system.
I would consider any of those acceptable for a library feature, but not for a language feature.
Good, thanks. If that represents shared opinion of (C)Python developers (so, there won't be claims like "MicroPython is not Python because it doesn't provide os.scandir()" (or hundred of other missing stdlib functions ;-) )) that's good enough already. With that in mind, I wished that any Python implementation was as complete and as efficient as possible, and one way to achieve that is to not add stdlib entities without real need (be it more API calls or more data types). So, I'm glad to know that os.scandir() passed thru Occam's Razor in this respect and specified the way it is really for common good. [] -- Best regards, Paul mailto:pmiscml@gmail.com