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

When Base has the unwrap function, we can avoid defining generic fall… #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

quinnj
Copy link
Member

@quinnj quinnj commented Jul 26, 2019

…back convert methods that cause lots of recompilation of convert methods. This improves the package load times from 1.4s to 1.0s for me. Fixes #177. Failures on nightly are unrelated

Relies on JuliaLang/julia#32613 for Base.unwrap

…back convert methods that cause lots of recompilation of convert methods. This improves the package load times from 1.4s to 1.0s for me. Fixes #177. Failures on nightly are unrelated

# Defined separately to avoid ambiguities
Base.convert(::Type{AbstractString}, x::CategoricalString) = x
Base.convert(::Type{T}, x::T) where {T <: CatValue} = x
Base.convert(::Type{Union{T, Missing}}, x::T) where {T <: CatValue} = x
Base.convert(::Type{Union{T, Nothing}}, x::T) where {T <: CatValue} = x

@static if isdefined(Base, :unwrap)
Copy link
Member

Choose a reason for hiding this comment

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

Please switch to a VERSION check once the PR is merged in Julia, so that Femtocleaner automatically removes the code the day we will require Julia 1.3.

# General fallbacks
Base.convert(::Type{S}, x::T) where {S, T <: CatValue} =
T <: S ? x : convert(S, get(x))
Copy link
Member

Choose a reason for hiding this comment

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

Just to be sure, do things like convert(CategoricalValue, x::CategoricalValue{String,UInt32}) work with this PR? That was handled by the T<:S branch.

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

Successfully merging this pull request may close these issues.

convert method for Any is not ideal
2 participants