Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

sorted() does shallow copy instead of deep copy #134470

Closed as not planned
Closed as not planned
Labels
type-bugAn unexpected behavior, bug, or error
@hyperkai

Description

@hyperkai

Bug report

Bug description:

sorted() does shallow copy instead of deep copy as shown below. *It's problematic:

originlist= ['apple','banana', ['kiwi','cherry']]newlist=sorted(originlist,key=len)print(newlist)# [['kiwi', 'cherry'], 'apple', 'banana']newlist[0][1]='CHERRY'newlist[2]='BANANA'print(newlist)# [['kiwi', 'CHERRY'], 'apple', 'BANANA']print(originlist)# ['apple', 'banana', ['kiwi', 'CHERRY']]# ↑↑↑↑↑↑↑↑

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp