djsegal
December 22, 2017, 5:21am
1
The only tools I know to get information about methods are:
methods()
methodswith()
(kind of) fieldnames()
How do you get information about the underlying method table though?
Is there a way to see how many methods there are in a table (at some point in time)?
djsegal
December 22, 2017, 5:34am
2
Something that gets you close to this is:
function get_all_symbols(cur_package::Module)
all_symbols = []
for cur_name in cur_package.names(cur_package, true)
Base.isidentifier(cur_name) || continue
in(cur_name, (Symbol(cur_package), :eval)) && continue
push!(all_symbols, cur_name)
end
all_symbols
end
You can check whether a binding is callable with isa(x, Base.Callable)
, which I believe implies it should have a method table entry.
1 Like
djsegal
December 22, 2017, 10:57pm
4
Would this be able to differentiate:
foo(bar::Baz
)
foo(bar::Fizz.Buzz)
?
djsegal
December 22, 2017, 10:59pm
5
Might have just answered that myself. Current func Iām working with:
function get_method_count(cur_package::Module)
method_count = 0
for cur_name in cur_package.names(cur_package, true)
isdefined(cur_package, cur_name) || continue
cur_obj = getfield(cur_package, cur_name)
isa(cur_obj, Base.Callable) || continue
method_count += length(methods(cur_obj))
end
method_count
end
A bit random question but do you intentionally put blank lines between all lines of code? It makes it difficult to read it.