Skip to content

Feature request: Collect to Vector #47777

Open
@jakobnissen

Description

@jakobnissen

As far as I can tell, there is currently no idiomatic way of collecting an arbitrary iterable into a Vector{T}. To me this seems like a basic operation. At least, I need it quite often.

  • collect does not always return a Vector
  • Array comprehensions calls collect on a Generator, which preserves shape information in some cases. Hence, it does not always return Vector
  • vec(collect(itr)) returns an array with shared memory. I believe this can be problematic sometimes, but I'm not completely sure.
  • [i for i in itr if true] does work, but is not exactly idiomatic. Also, I don't think it's documented to return a Vector.

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrays[a, r, r, a, y, s]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions