-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Wishlist: caching source code #23448
Comments
See also #2625. |
I also want this, but it's definitely not 1.0-blocking since we can always add this functionality in 1.x. |
Maybe i'm looking into the wrong direction, but isn't a reference of filename/path/linenumber from-to enough? |
The underlying file might have been modified since parsing. |
Good point, I moved the milestone to 1.x. |
Just do add another +1 for this, it would allow me to greatly simplify Query.jl in one key part. |
Implemented as part of #23898. |
Closed by #23898. You can get the raw source code (as text) from |
@timholy From your comment in #22721
I expected that there would be a new function |
You don't need #23898 for that, you can do that now: julia> foo(x::Int) = 1
foo (generic function with 1 method)
julia> foo(x::Float64) = 2
foo (generic function with 2 methods)
julia> m = first(methods(foo, Tuple{Float64}))
foo(x::Float64) in Main at REPL[2]:1
julia> Base.uncompressed_ast(m)
CodeInfo(:(begin
nothing
return 2
end)) The reason I want(ed) that for #22721 is because with renaming, the types need to be interpreted syntactically not semantically. #23898 is something simpler: some folks seemed to want the source pre-parsing (e.g., to preserve whitespace), so I decided just to store the raw text to make sure everyone could use it. For Revise, the main advantage is that in timholy/Revise.jl#49 it's no longer necessary to parse all the source files when you first load a package: you can afford to wait until you detect that some file has changed, and just focus on the changed files. That reduces the overhead from loading. (You couldn't do that before, because once the file changes you can't "go back" and figure out what the original looked like, but now that there's a cache this is straightforward.) |
Doesn't |
I have exactly the same need as @cstjean, i.e. I would love to have easy access to the original AST of an arbitrary function, not the lowered version. |
You can already get it now for Base or any precompiled package if you're willing to parse the cache. Check two open PRs in Revise for guidance about how to do that (how to get the source text, and how to localize a specific method signature). It would be nice to have an extra field in a |
For my use-case in Query.jl I would need this to work for arbitrary functions, not just things in Base or packages. Completely understood why you took the approach you did for your use-case! |
How about opening a new issue with your specific requirements? |
#2625 also requires a general solution that works for e.g. anonymous functions. |
Several of us would like it if Julia maintained a source-text cache for all code, in addition to the current cache for lowered/inferred/compiled code. (See #22721, with "votes" from developers of Revise, Gallium, and a tracing package.)
I'm putting a 1.0 milestone on the decision, but I'm afraid I lack the time to work on the implementation of this feature. Feel free to remove this from the milestones as appropriate.The text was updated successfully, but these errors were encountered: