Skip to content
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

Don't show built-in modules in whos() #19999

Merged
merged 3 commits into from
Jan 16, 2017
Merged

Conversation

malmaud
Copy link
Contributor

@malmaud malmaud commented Jan 12, 2017

It's very time-consuming (almost 10 seconds on my machine) to compute the summarysize of Base, Core, and Main, making whos() an impractical tool for quickly seeing my custom workspace variables. It also seems like unnecessary information, since those modules are always available at the REPL and almost never need to be explicitly accessed.

Thus, I propose not showing those by default. They're still available with whos(r".*").

@@ -667,7 +667,7 @@ Print information about exported global variables in a module, optionally restri

The memory consumption estimate is an approximate lower bound on the size of the internal structure of the object.
"""
function whos(io::IO=STDOUT, m::Module=current_module(), pattern::Regex=r"")
function whos(io::IO=STDOUT, m::Module=current_module(), pattern::Regex=r"^(?!.*(Base|Main|Core)).*$")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would also filter names like StatsBase. Maybe it should just skip calling summarysize on value in (Base, Main, Core)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I gave that a go.

@kshyatt kshyatt added display and printing Aesthetics and correctness of printed representations of objects. modules labels Jan 12, 2017
@malmaud
Copy link
Contributor Author

malmaud commented Jan 13, 2017

Good now, @vtjnash ?

bytes = summarysize(value)
if bytes < 10_000
@printf(head, "%6d bytes ", bytes)
if s ∈ ("Base", "Main", "Core")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do exactly value ∈ (Base, Main, Core), so that it filters those exact items, and not something with the same name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@printf(head, "%6d KB ", bytes ÷ (1024))
bytes = summarysize(value)
if bytes < 10_000
@printf(head, "%6d bytes ", bytes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe should use prettyprint_getunits, if we're going to print contractions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we save that for another PR, since it's not really related to my change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, right yes. Github mislead me with the indentation change highlighting to think you were adding it

@malmaud
Copy link
Contributor Author

malmaud commented Jan 16, 2017

Windows failure seems unrelated

@malmaud malmaud merged commit a1f232e into JuliaLang:master Jan 16, 2017
@malmaud malmaud deleted the jmm/whos branch January 16, 2017 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
display and printing Aesthetics and correctness of printed representations of objects. modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants