-
Notifications
You must be signed in to change notification settings - Fork 222
Support pathlib.Path in Python API #1535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
If pathlib supports It's worth a try, although you need to consider different and specifically old Python versions down to 2.7 which is still in use. |
It does in fact support casting to string. Afaik since it was added, it has always supported |
Problem is probably that converting to That's the price for binding C++ concepts to a dynamic language :( |
Hmm, I can't see a downside in this case to do a conversion to string. Any object that would be passed to a parameter being used as a path should be or at least expect to be casted to a string (the low level function in python to handle paths are all string based). So even if you were to stringify a numpy array or something, I think the error should be readable? |
That true, but there is a overload selection pass first. So let's say there is a method with two overloads:
implicitly doing a |
Regarding the numpy approach: I have not really considered that case, but that is an interesting option. Referring to #1530 I'm not sure about the performance penalty of the string back and forth conversion, but at least the loops are executed in C++ space then. I'm always surprised how much is still missing ... I though the API is pretty complete :( |
Ah, sorry, I think I mixed up stuff a bit. I was purely referring to load/read/write cases that expect a string. All of the one I have used, use path as the first parameter in all function footprints. In that case I would argue the conversion is safe, or is it not? Regarding numpy, I can reply directly in that issue. |
Issue #1535 - calling str(x) implicitly in RBA and pya
Hi, I always forget to cast Paths to strings while using the Python API. For example
will fail as
some_path / "netlist.spice"
is not actually supported and needs to be converted to a string . I was wondering would there be a simple way to do this conversion in the KLayout API side before the underlying C++ calls instead?The text was updated successfully, but these errors were encountered: