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

Change Union types sort order #22664

Closed
quinnj opened this issue Jul 3, 2017 · 6 comments
Closed

Change Union types sort order #22664

quinnj opened this issue Jul 3, 2017 · 6 comments
Labels
types and dispatch Types, subtyping and method dispatch

Comments

@quinnj
Copy link
Member

quinnj commented Jul 3, 2017

The order of types in a Union should be mostly irrelevant, but with WIP work on inline, isbits Union types, the "default initialization" for Arrays requires the underlying Union selector byte to be zeroed out (otherwise an array element could be tagged as an "out of bounds" type for the Union). There are a few conveniences if the Union types sort order followed a pattern like:

  1. Singleton types
  2. Sizeof isbits types
  3. All reference types....alphabetically?
@ararslan ararslan added the types and dispatch Types, subtyping and method dispatch label Jul 3, 2017
@nalimilan
Copy link
Member

For a bit of context, it would be convenient if Union{T, Null} and Union{Null, T} had identical coding of their type tags, with 0 denoting Null. This is the convention used by Pandas, PostgreSQL, SQLite and Arrow/Feather. See also #18507. So sorting singleton types first would handle this case.

@quinnj
Copy link
Member Author

quinnj commented Jul 11, 2017

Do we already have code that sorts Union types? Or is that just enforced in the show method for Unions? I'm happy to take a crack at this if someone could give a few tips or places to look/start.

@vtjnash
Copy link
Member

vtjnash commented Jul 12, 2017

No, show just sorts them alphabetically while printing them

@JeffBezanson
Copy link
Member

Should probably be done in jl_type_union in jltypes.c, which handles normalization (currently, removing types subsumed by others in a union).

@quinnj
Copy link
Member Author

quinnj commented Jul 12, 2017

Yeah, I'm stepping through that function right now actually. Is it ok if I just do a separate sort call after normalization but before the Union structs are made?

@JeffBezanson
Copy link
Member

Yes that sounds fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

No branches or pull requests

5 participants