-
Notifications
You must be signed in to change notification settings - Fork 17
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
Excessive type instability in this package #117
Comments
FWIW, it feels like you're conflating type safety and stability. The type instability concerns associated with using
If you disagree with either of these assumptions, feel free to share specific examples or alternatives. Simply listing operations that aren't type stable isn't very helpful because it's hard to determine the overall impact relative to the convenience. Having looser constraints often improves code readability and usability, so without more context it's hard to prioritize changing that.
And it still usually does because even if the
Specific suggestions or PRs are always welcome :) |
Right, sorry, I was being imprecise. I use this package for type safety. I agree that for file operations, the performance impact of small type instabilities is usually negligible. However, type instability does interfere with type safety tools like JET or Cthulhu. When the compiler can't infer what types you have before runtime, it can't make any promises before runtime, either. So my issue is this: Given that type safety is the number one reason to use path types in the first place, it's a shame that type instabilities prevent the user from actually getting verifiable, analyzable type safety. |
Hmm, I see. I'm not familiar with JET, but Cthulhu.jl as I understand it's intended more for debugging inference issues like invalidation, rather than enforcing any kind of type safety. If the instabilities are making it hard to debug the Cthulhu.jl output, my understanding is that you can actually run the code in question and it'll figure out the runtime types for you? |
FWIW, there are some cases where we can do better about knowing types at compile time (e.g., default system path behaviour). Turns out the Basically, since Julia decided several years ago that Again, I think improving type stability where possible is a good idea to help in reading output from Cthulhu.jl, but I don't think it should override easy-of-use/interop with Base.Filesystem. |
I encountered some severe type instabilities in code using this package. When attempting to fix the type instability, I discovered that it runs deep in this package.
For example:
PosixPath
stores an NTuple of strings. When N is not known at compile time, this is much less efficient than storing a vectorjoin
is completely type unstable in multiple ways: The splatting of the unknown-sized tuple, the fact thatp
can be any of multiple types, the fact thatp
can switch type halfway throughPath
function is fundamentally unstable due to howoverride
works.To me at least, one of the major promises of this package is increased type safety: I use
AbstractPath
instead ofString
because it allows better static analysis, and catches more bugs. But this is hindered when the code is so opaque to the compiler.It would be nice if this package became type stable.
The text was updated successfully, but these errors were encountered: