Skip to content

Add primitive for list.copy #1092

@JukkaL

Description

@JukkaL

We have a primitive for dict.copy but not list.copy, even though both operations are supported:

>>> [1, 3].copy()
[1, 3]

The implementation would be a C function with similar structure to CPyDict_Copy. A shallow copy can be made using PyList_GetSlice(list, 0, PyList_GET_SIZE(list)). If the object type is not exactly list (i.e. it's an instance of a subclass), use a generic call to copy(), since it might return an instance of the subclass.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions