-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
sndhdr.whathdr could return a namedtuple #62815
Comments
Both sndhdr.whathdr an sndhdr.what returns a tuple with various information, while it could return a namedtuple. I attached a patched for this, with tests as well. |
Ping, please review. I guess it is minimal enough to get into 3.4. |
Ping. :) |
Personally I doubt it is a good idea to convert any tuple to named tuple. There are downsides: this increases memory usage and decreases performance; this changes pickled data and makes it backward incompatible (and even worse with other serialization methods). |
But it improves the API. It's much nicer to actually access the values returned by sndhdr as f.type, f.sampling_rate, f.channels than f[0], f[1], f[2]. You do have a point though. Would it be more acceptable if we'll provide a new function which returns a namedtuple and leaving |
Serhiy, if there's no actual gain in changing this, should we close the issue? |
This is a reasonable improvement. It was what named tuples were intended to be used for. |
If Raymond found this feature helpful, I have no strong objection. Only several comments:
|
Thanks, Serhiy, for the review. Here's the updated version. |
A namedtuple is still wrongly documented. |
Here's a new version. It adds versionchanged directive for 'whathdr' and 'what'. Serhiy, I hope that now I got right the documentation of the return type. I didn't understand at first what was wrong. |
The documentation says: """ But actual attributes of returned namedtuple are filetype, framerate, nchannels, nframes and sampwidth. |
Thanks. |
Serhiy, is there anything left to do for this patch? |
The patch looks good. I'll apply it shortly. |
New changeset ef72142eb8a2 by R David Murray in branch 'default': |
Committed. Thanks, Claudiu. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: