Skip to content

Commit 1e0b4e6

Browse files
committed
Skip Base and Core by default in install_speculator
1 parent e09ca4a commit 1e0b4e6

File tree

6 files changed

+24
-29
lines changed

6 files changed

+24
-29
lines changed

.github/workflows/regenerate_readme.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ jobs:
2020
- run: |
2121
git config user.name github-actions
2222
git config user.email github-actions@github.com
23-
git diff --quiet || (git add . && git commit -m "Regenerate `README.md`")
23+
git diff --quiet || (git add . && git commit -m 'Regenerate `README.md`')
2424
git push

NEWS.md

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,12 @@
33

44
## v0.1.0
55

6-
- `speculate(predicate, value; parameters...)`: Search for compilation directives
7-
- `predicate`: Filter values found in a `Module`
8-
- `value`: The initial value to search
9-
- `parameters`
10-
- `background`: Whether to search in a background process
11-
- `dry`: Whether to call `precompile` on generated methods
12-
- `limit`:
13-
The maximum number of compilable methods that may be generated from a generic method
14-
- `path`: A file to write compilation directives to
15-
- `verbosity`: Specifies which logging statements to show
16-
- Input Speculators
17-
- `install_speculator`: Automatically calls `speculate` on values input to the REPL
18-
- `uninstall_speculator`: Removes the automatic input speculator
19-
- `Verbosity`: A set used to specify which logging statements to show
6+
- `speculate`: Search for compilation directives
7+
- `install_speculator`: Automatically calls `speculate` on values input to the REPL
8+
- `uninstall_speculator`: Removes the automatic input speculator
9+
- `Verbosity`: A set used to specify which logging statements to show in `speculate`
2010
- `debug`: Shows each successful compilation directive
2111
- `review`: Summarizes the generated compilation directives
2212
- `silent`: Shows no logging statements
2313
- `warn`: Shows each unsuccessful compilation directive
24-
- `all_modules::AllModules`: A value used to `speculate` each loaded module
14+
- `all_modules::AllModules`: A singleton constant used to `speculate` every loaded module

docs/source/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
## Introduction
55

6-
Speculator.jl reduces latency by automatically searching for compilation directives.
6+
Speculator.jl reduces latency by automatically searching for compilable methods.
77

88
## Usage
99

src/input_speculators.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ function install_speculator!(
2424
end
2525

2626
"""
27-
install_speculator(predicate = Returns(true); background::Bool = true, parameters...)
27+
install_speculator(
28+
predicate = (m, _) -> m ∉ [Base, Core]; background::Bool = true,
29+
parameters...)
2830
29-
Install an input speculator that calls
31+
Install a hook that calls
3032
`speculate(predicate,\u00A0value;\u00A0background,\u00A0parameters...)`
3133
on each input `value` in the REPL.
3234
@@ -53,7 +55,9 @@ julia> g(::Union{String, Symbol}) = nothing;
5355
[ Info: Compiled `Main.Example.g(::Symbol)`
5456
```
5557
"""
56-
function install_speculator(predicate = default_predicate; background::Bool = true, parameters...)
58+
function install_speculator(
59+
predicate = (m, _) -> m [Base, Core]; background::Bool = true, parameters...
60+
)
5761
@nospecialize
5862
if isinteractive()
5963
if is_repl_ready()

src/speculate.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,15 @@ end
170170
speculate(predicate, value; parameters...)
171171
speculate(value; parameters...)
172172
173-
Search for compilation directives.
173+
Search for compilable methods.
174174
175175
See also [`install_speculator`](@ref).
176176
177177
!!! tip
178178
Use this in a package to reduce latency.
179179
180180
!!! note
181-
Speculation only runs when called during precompilation or an interactive session,
181+
This only runs when called during precompilation or an interactive session,
182182
or when writing precompilation directives to a file.
183183
184184
# Parameters
@@ -189,10 +189,9 @@ See also [`install_speculator`](@ref).
189189
whereas returning `false` specifies to ignore the value.
190190
This is called when searching the names of a `Module` if the
191191
given module and name satisfy `isdefined` and `!isdeprecated`.
192-
The default predicate `Returns(true)` will search everything possible,
193-
up to the generic `limit`, whereas the predicate
194-
`Returns(false)` will only generate methods from
195-
callable values passed directly to `speculate`.
192+
The default predicate `Returns(true)` will search every value,
193+
whereas the predicate `Returns(false)` will only generate
194+
methods from callable values passed directly to `speculate`.
196195
Some useful predicates include `Base.isexported`,
197196
`Base.ispublic`, and checking properties of the value itself.
198197
- `value`:
@@ -205,7 +204,7 @@ See also [`install_speculator`](@ref).
205204
# Keyword parameters
206205
207206
- `background::Bool = false`:
208-
Specifies whether to precompile on a thread in the `:default` pool.
207+
Specifies whether to run on a thread in the `:default` pool.
209208
The number of available threads can be determined using `Threads.nthreads(:default)`.
210209
- `dry::Bool = false`:
211210
Specifies whether to run `precompile` on generated method signatures.

test/runtests.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ end
5858
@test isempty(silent)
5959
@test !isempty(debug)
6060
@test issetequal(silent debug review, debug review)
61+
@test setdiff(debug, debug) == silent
62+
@test setdiff(review debug, debug) == review
6163
end
6264

6365
@testset "`initialize_parameters`" begin
@@ -130,8 +132,8 @@ end
130132

131133
path = tempname()
132134
f() = nothing
133-
@test_logs (:info, "Compiled `Main.f()`") speculate(f; path, verbosity = debug)
134-
@test_logs (:info, "Skipped `Main.f()`") speculate(f; path, verbosity = debug)
135+
@test_logs (:info, r"Compiled `.*f\(\)`") speculate(f; path, verbosity = debug)
136+
@test_logs (:info, r"Skipped `.*f\(\)`") speculate(f; path, verbosity = debug)
135137

136138
@test_throws ErrorException Speculator.wait_for_repl()
137139

0 commit comments

Comments
 (0)