[Python-Dev] Add transform() and untranform() methods (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Fri Nov 15 12:45:31 CET 2013
- Previous message: [Python-Dev] Add transform() and untranform() methods
- Next message: [Python-Dev] Add transform() and untranform() methods
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 15 November 2013 20:33, Antoine Pitrou <solipsis at pitrou.net> wrote:
On Fri, 15 Nov 2013 21:28:35 +1100 Steven D'Aprano <steve at pearwood.info> wrote:
One benefit is: import codecs codec = getnameofcompressioncodec() result = codecs.encode(data, codec) That's a good point. If encoding/decoding is intended to be completely generic (even if 99% of the uses will be with strings and bytes), is there any reason to prefer built-in functions rather than methods on object? Practicality beats purity. Personally, I've never used codecs on anything else than str and bytes objects.
The reason I'm now putting some effort into better documenting the status quo for codec handling in Python 3 and filing off some of the rough edges (rather than proposing adding any new APIs to Python 3.x) is because the users I care about in this matter are web developers that already make use of the binary codecs and are adopting the single-source approach to handle supporting both Python 2 and Python 3. Armin Ronacher is the one who's been most vocal about the problem, but he's definitely not alone.
A new API for binary transforms is potentially an academically interesting concept, but it solves zero current real world problems. By contrast, being clear about the fact that codecs.encode and codecs.decode exist and are available as far back as Python 2.4 helps to eliminate a genuine barrier to Python 3 adoption for a subset of the community.
Cheers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-Dev] Add transform() and untranform() methods
- Next message: [Python-Dev] Add transform() and untranform() methods
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]