Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pathlib.Path should have a copy() method #68417

Closed
jshholland mannequin opened this issue May 18, 2015 · 6 comments
Closed

pathlib.Path should have a copy() method #68417

jshholland mannequin opened this issue May 18, 2015 · 6 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@jshholland
Copy link
Mannequin

jshholland mannequin commented May 18, 2015

BPO 24229
Nosy @pfmoore, @pitrou, @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2016-02-24.19:42:09.841>
created_at = <Date 2015-05-18.16:35:13.956>
labels = ['type-feature', 'library']
title = 'pathlib.Path should have a copy() method'
updated_at = <Date 2016-02-24.19:42:09.841>
user = 'https://bugs.python.org/jshholland'

bugs.python.org fields:

activity = <Date 2016-02-24.19:42:09.841>
actor = 'serhiy.storchaka'
assignee = 'none'
closed = True
closed_date = <Date 2016-02-24.19:42:09.841>
closer = 'serhiy.storchaka'
components = ['Library (Lib)']
creation = <Date 2015-05-18.16:35:13.956>
creator = 'jshholland'
dependencies = []
files = []
hgrepos = []
issue_num = 24229
keywords = []
message_count = 6.0
messages = ['243494', '243495', '243515', '243517', '243521', '243583']
nosy_count = 4.0
nosy_names = ['paul.moore', 'pitrou', 'serhiy.storchaka', 'jshholland']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue24229'
versions = ['Python 3.4', 'Python 3.5', 'Python 3.6']

@jshholland
Copy link
Mannequin Author

jshholland mannequin commented May 18, 2015

Path objects already have rename() and replace() methods; it would be useful for them also to have a copy() method to simplify that operation.

I'll look into putting a patch together this evening.

@jshholland jshholland mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels May 18, 2015
@serhiy-storchaka
Copy link
Member

Path objects are immutable, so the copy method is not needed.

@pfmoore
Copy link
Member

pfmoore commented May 18, 2015

I presume the copy method is intended as a file copy, not for copying the object. But calling the method copy() is likely to be confusing, precisely as happened here :-)

@pitrou
Copy link
Member

pitrou commented May 18, 2015

If copy() has a mandatory argument, it can't really be mixed up with an object-cloning method.

@serhiy-storchaka
Copy link
Member

File renaming is simple and usually atomic operation. File copying is complex operation. What memory buffer should be used for copying? What to do with growing files or reading with errors? Should file space be preallocated before copyiong to decrease fragmentation? How handle sparse files? Can be optimized copyiong on file systems with compression? What to do with NT streams? What to do with extended attributes? What to do with directories, links and other special files?

I think that pathlib is not good place for this function (as well as for handling ZIP files or playing multimedia).

@jshholland
Copy link
Mannequin Author

jshholland mannequin commented May 19, 2015

Serhiy makes a series of good points, which I hadn't really considered before filing this report. It was mostly laziness on my part while dashing off a quick script - I knew I wouldn't have to deal with the edge cases so subconsciously dismissed them, especially as the code I wrote to copy was only a couple of lines.

So I'm happy for this bug to be closed with no change needed.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants