Skip to content

Document type specialization #23471

Closed
Closed

Description

On 0.6.0,

foo1(t::Type, x)            = Nullable{t}(sin(x))
foo2(t::Type{T}, x) where T = Nullable{t}(sin(x))

@btime foo1(Float64, 2)
  408.815 ns (2 allocations: 48 bytes)    # same with @allocated
@btime foo2(Float64, 2)
  17.359 ns (0 allocations: 0 bytes)

However, both functions are @inferred correctly, and have the same @code_llvm. Why does foo1 allocate?

Might be related to #19137

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    docsThis change adds or pertains to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions