Skip to content

Commit 64b9a95

Browse files
committed
Implement list.copy as node
1 parent 990d652 commit 64b9a95

File tree

2 files changed

+14
-7
lines changed
  • graalpython

2 files changed

+14
-7
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,20 @@ public static ListExtendNode create() {
419419
}
420420
}
421421

422+
// list.copy()
423+
@Builtin(name = "copy", minNumOfPositionalArgs = 1)
424+
@GenerateNodeFactory
425+
public abstract static class ListCopyNode extends PythonUnaryBuiltinNode {
426+
427+
@Specialization(limit = "3")
428+
PList copySequence(PList self,
429+
@Cached SequenceStorageNodes.CopyNode copy,
430+
@CachedLibrary("self") PythonObjectLibrary plib) {
431+
return factory().createList(plib.getLazyPythonClass(self), copy.execute(self.getSequenceStorage()));
432+
}
433+
434+
}
435+
422436
// list.insert(i, x)
423437
@Builtin(name = "insert", minNumOfPositionalArgs = 3)
424438
@GenerateNodeFactory

graalpython/lib-graalpython/list.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@
3838
# SOFTWARE.
3939

4040

41-
def copy(self):
42-
return self[:]
43-
44-
45-
list.copy = copy
46-
47-
4841
def sort(self, key=None, reverse=False):
4942
if reverse:
5043
if key:

0 commit comments

Comments
 (0)