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

Does LittleDict show too much about the implementation? #66

Open
PallHaraldsson opened this issue Oct 23, 2020 · 3 comments
Open

Does LittleDict show too much about the implementation? #66

PallHaraldsson opened this issue Oct 23, 2020 · 3 comments

Comments

@PallHaraldsson
Copy link
Contributor

PallHaraldsson commented Oct 23, 2020

I noticed:

julia> x = LittleDict{String, Int}()
LittleDict{String, Int64, Vector{String}, Vector{Int64}}()

should it show similar to other Dicts:

LittleDict{String, Int64}()

I also noticed for a recursive one:

julia> x = LittleDict{LittleDict, Int}()
LittleDict{LittleDict, Int64, Vector{LittleDict}, Vector{Int64}}()

julia> x
LittleDict{LittleDict, Int64, Vector{LittleDict}, Vector{Int64}} with 1 entry:
  LittleDict{LittleDict, Int64, Vector{LittleDict}, Vector{Int64}}(#= circular reference @-1 =#) => 0

this "circular reference" is not shown for other dicts (I'm not saying it's untrue). I just noticed this compared to: #65.

@CameronBieganek
Copy link

should it show similar to other Dicts:

LittleDict had 4 type parameters, and it's pretty normal for types to print all of their type parameters. There are similarly hard to read examples in Base:

julia> Iterators.take((i for i in 1:10), 5)
Base.Iterators.Take{Base.Generator{UnitRange{Int64}, typeof(identity)}}(Base.Generator{UnitRange{Int64}, typeof(identity)}(identity, 1:10), 5)

We would need to add a show method to LittleDict to customize the printing, but I think it's misleading to use show to hide some of the type parameters.

@ericphanson
Copy link
Member

We would need to add a show method to LittleDict to customize the printing, but I think it's misleading to use show to hide some of the type parameters.

I don't think it is! IMO we should have a nice clean show. Currently, since AWS.jl uses LittleDicts all over, I get

julia> S3.list_objects_v2("BUCKET", Dict("delimiter" => "/"); aws_config=aws)
OrderedCollections.LittleDict{Union{String, Symbol}, Any, Vector{Union{String, Symbol}}, Vector{Any}} with 7 entries:
  "Name"           => "BUCKET"
  "Prefix"         => OrderedCollections.LittleDict{Union{String, Symbol}, Any, Vector{Union{String, Symbol}
  "KeyCount"       => "2"
  "MaxKeys"        => "1000"
  "Delimiter"      => "/"
  "IsTruncated"    => "false"
  "CommonPrefixes" => Any[OrderedCollections.LittleDict{Union{String, Symbol}, Any, Vector{Union{String, Sym

The LittleDict printing here is verbose and not telling me much. Turns out some of those are empty as well!

@CameronBieganek
Copy link

Yeah, I suppose that the K and V types are part of the AbstractDict API, so it makes sense to print those type parameters but not the other ones, which are just implementation details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants