-
-
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
"whos" is a bad name for the functionality #12131
Comments
Agree - but perhaps a suggestion for a better name? We used to have sizes and they got removed at some point. |
Maybe Anyway, +1 to a better name. |
Random thoughts: (i wasn't even aware that 'who' exists in matlab)
as commands P.S. workspace() for cleaning up could also use a better name -> new_workspace() |
Tangentially, I posted a pull request to report sizes in whos. It is still open, but I don't have the number handy. |
Also, if |
I think that this function conflates two rather different things:
Perhaps the APIs to discover these things should not be crammed into one. |
I agree a separate function just to get a list of names should exist. But for the second function, returning the memory used by each object, you obviously need to also return the names to identify them. |
|
It would be nice to just get rid of whos, even if by just renaming it to something better - possibly for 0.4 |
I like |
|
You also get information about the size and the location using bash's P.S. Can |
👎 on calling it |
Programming languages and operating systems are replete with the overly Julia is becoming ever more an engaging conversationalist -- the community There are many fine short words. +1 for those that are transparent in use. On Sun, Jul 26, 2015 at 6:36 AM, Scott P. Jones [email protected]
|
+1 for ls. And we could even do ls for names only and la for names+memory. |
Once there was COBOL... PERFORM UNTIL B = 0
MOVE A TO TEMP
MOVE B TO A
DIVIDE TEMP BY B GIVING TEMP REMAINDER B
END-PERFORM |
I know ls is l(i)s(t), what is la? On Mon, Jul 27, 2015 at 4:38 AM, Andreas Lobinger [email protected]
|
... on a lot of systems i visited the last years: an alias to ls -la so |
|
yezindeedee (and goodnight) On Mon, Jul 27, 2015 at 5:46 AM, Tony Kelman [email protected]
|
How about |
+1 |
+1 names() and restructure documentation, so it shows up in Essentials. |
+1 On Mon, Jul 27, 2015 at 9:39 AM, Andreas Lobinger [email protected]
|
This may be too much change, but... what if we change: whos() --> I always thought that resetting your session should not happen with a On Mon, Jul 27, 2015 at 9:38 AM, Andreas Lobinger [email protected]
|
+1 to Should the default be "global names in the current module" or "currently available unqualified names" (i.e. the set of names that you can use without prepending Also |
@tbreloff, I agree, |
Currently visible global names is a good default since it is hard to figure out whereas the names of a particular module is easy to ask for by doing names(M) where M is the module object.
|
Whatever it is called, let me make a plea to for For one thing, returning a value allows the caller to perform further processing on the data if desired. For another thing, returning a data structure allows for more flexible display, e.g. a |
Something like this? struct FieldDetail
name::Symbol
bytes::Int
summary::String
end
struct ObjectTable{O} <: AbstractArray{O, 1}
objects::Vector{O}
end
get_field_detail(anobject, asymbol) = begin
value = getfield(anobject, asymbol)
FieldDetail(asymbol, summarysize(value), summary(value))
end
global_details(m::Module, pattern = r"") = ObjectTable([
get_field_detail(m, v)
for v in sort!(names(m))
if isdefined(m, v) && ismatch(pattern, string(v))
])
IndexStyle(t::ObjectTable) = IndexLinear()
size(t::ObjectTable) = size(t.objects)
getindex(t::ObjectTable, i::Int) = getindex(t.objects, i)
setindex!(t::ObjectTable, v, i::Int) = setindex!(t.objeccts, v, i)
Base.showarray(io::IO, o::ObjectTable, repr::Bool) = begin
fnames = fieldnames(eltype(t))
Base.show(io,
Markdown.MD([Markdown.Table(
unshift!(
map(t.objects) do object
string.(getfield.(object, fnames))
end,
string.(fnames)),
repeat([:l], inner = length(fnames)))]))
end
|
Adding an entire new kind of array just for this case seems like overkill to me. |
Eh, maybe. I needed a new type to avoid the default show methods for vector. Here's another more explicit implementation:
ObjectTables (or an object table function) seem more broadly useful to me. For example, they are a nice way to print a vector of NamedTuples. |
Yes, I think this is a great use case for a lightweight built-in dataframe-like type. |
This kind of lightweight table-like structure is needed in many applications, so it would indeed be great to have a standard way of representing them. That would prevent people from misusing DataFrames for this as is too often the case (probably inspired by what R does). |
Question: fieldnames are statically known to the compiler, right? I don't see this reflected in the output of |
Much simpler solution: whenever NamedTuples drop in base, have an Vector of NamedTuples print as a markdown table. Then whos could simply return a vector of NamedTuples. |
I like |
|
if that, maybe |
Maybe we should have someone who should be assigned for this? |
The only thing to do here is rename |
@StefanKarpinski, doesn't it also have to be changed to return a data structure instead of printing via side effects? |
We're getting down to crunch time for 1.0 feature freeze and that seems pretty featurey to me. Since this is strictly interactive functionality, as long as the name correct for 1.0, we can change what it returns and how info gets printed in 1.x. Changing from returning nothing and printing info to returning a value with special display is the safer direction anyway. Given that, I'm leaving this issue to address only the name change with a 1.0 milestone. You can open a 1.x feature that proposes changing the function to return a value with special printing. |
It might be good to just have it return a |
Regardless, that can be done at any point in the future. |
Note: In #12131, `whos` was renamed to `varinfo`. However, the name `whos` still appears in the `HISTORY.md` file, and thus we probably need to ignore it from `codespell`.
Of course it was named by analogy of the matlab command. But
whos
is one of the more obscure names in julia. If at all,who
should give users, not things. Second, the "s" in "whos" seems to be a contraction of "who + sizes" , makingwhos
an extended version ofwho
in matlab. In julia there is nowho
of course andwhos
does not report sizes. I am a bit ashamed of reporting this, but apparently I care.The text was updated successfully, but these errors were encountered: