Skip to content

nested broadcast should evaluate non-broadcasted part once #25340

@tpapp

Description

@tpapp

MWE following discussion:

struct Bar
    data
    Bar(data) = (println("expensive"); new(data))
end
(B::Bar)(x) = B.data * x
Bar(2).([1,2,3])                  # Bar(2) will be only evaluated once
broadcast(sqrt, Bar(2).([1,2,3])) # Bar(2) will also be evaluated once
sqrt.(Bar(2).([1,2,3]))           # Bar(2) will be evaluated three times

Metadata

Metadata

Assignees

No one assigned

    Labels

    broadcastApplying a function over a collectionperformanceMust go faster

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions