How to get count of current methods in a package's methodtable?

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)?

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)


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

Would this be able to differentiate:

  • foo(bar::Baz)
  • foo(bar::Fizz.Buzz)


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))


A bit random question but do you intentionally put blank lines between all lines of code? It makes it difficult to read it.