Re: [Python-Dev] cpython (merge 3.3 -> default): merge from 3.3

2013-09-11 Thread Antoine Pitrou
On Thu, 12 Sep 2013 07:57:25 +0200 (CEST) senthil.kumaran wrote: > > +<<< local > Optional argument random is a 0-argument function returning a > random float in [0.0, 1.0); if it is the default None, the > standard random.random will be used. > +=== > +

Re: [Python-Dev] Need testing audio files

2013-09-11 Thread Ben Finney
Serhiy Storchaka writes: > I work on enhancement of audio modules testing [1], and I need free > (in both senses) small sample audio files in different formats. The Internet Archive https://archive.org/> has a wide selection of free-software media, many of which have free license terms that woul

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Ethan Furman
On 09/11/2013 02:39 PM, Tim Delaney wrote: On 12 September 2013 02:03, Ethan Furman mailto:et...@stoneleaf.us>> wrote: On 09/11/2013 08:49 AM, Victor Stinner wrote: 2013/9/11 Ethan Furman mailto:et...@stoneleaf.us>>: He isn't keeping the key unchanged (notice no white s

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Tim Delaney
On 12 September 2013 02:03, Ethan Furman wrote: > On 09/11/2013 08:49 AM, Victor Stinner wrote: > >> 2013/9/11 Ethan Furman : >> >>> He isn't keeping the key unchanged (notice no white space in MAPPING), >>> he's >>> merely providing a function that will automatically strip the whitespace >>> fro

Re: [Python-Dev] Need testing audio files

2013-09-11 Thread Serhiy Storchaka
11.09.13 17:10, Barry Warsaw написав(ла): I have some pro-audio recording capabilities and would be happy to generate some copyright-donated clips for Python. Please contact me off-list if needed. Thank you. ___ Python-Dev mailing list Python-Dev@p

Re: [Python-Dev] Need testing audio files

2013-09-11 Thread Terry Reedy
On 9/11/2013 10:10 AM, Barry Warsaw wrote: On Sep 11, 2013, at 01:09 PM, Serhiy Storchaka wrote: In ideal it should be one high-quality (float64?) multichannel (5+1?) but short master file and it's lower-quality copies made by third-party tools. In ideal the content should be related to Python.

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Ethan Furman
On 09/11/2013 10:49 AM, Antoine Pitrou wrote: What I dislike is the idea of doing additional work because some barriers are imposed ;-). PEP or PyPI are on a similar scale here. At least a PEP would help record the various discussion details, so I'd favour that over the PyPI path. I would thin

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Antoine Pitrou
On Wed, 11 Sep 2013 19:31:56 +0200 "Martin v. Löwis" wrote: > Am 11.09.13 15:04, schrieb Antoine Pitrou: > > There are not many possible APIs to create case-insensitive dicts, or > > identity dicts. > > That is certainly not true. Most obviously, you have the choice of a > specialized case-mappi

Re: [Python-Dev] Need testing audio files

2013-09-11 Thread Serhiy Storchaka
11.09.13 17:10, Oleg Broytman написав(ла): Wouldn't his name be enough? http://www.python.org/~guido/guido.au It is Lib/test/audiotest.au. 1-channel and 8-bit. No, it wouldn't enough. ___ Python-Dev mailing list Python-Dev@python.org https://mai

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Martin v. Löwis
Am 11.09.13 15:04, schrieb Antoine Pitrou: > There are not many possible APIs to create case-insensitive dicts, or > identity dicts. That is certainly not true. Most obviously, you have the choice of a specialized case-mapping dict, or a generalized type that can be used for case mapping also. Do

Re: [Python-Dev] Need testing audio files

2013-09-11 Thread Serhiy Storchaka
11.09.13 15:46, Victor Stinner написав(ла): Use your microphone, say "python" and save the file in your favorite file format. Try for example Audacity. I suppose that you don't need specific audio content and you don't need a huge file. My voice is even more ugly than my English. I don't want p

Re: [Python-Dev] Need testing audio files

2013-09-11 Thread Serhiy Storchaka
11.09.13 15:45, Antoine Pitrou написав(ла): If you want to edit, shorten, convert sounds between different formats, you can try Audacity, a free sound editor: http://audacity.sourceforge.net/ Yes, Audacity is great. ___ Python-Dev mailing list Pytho

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Serhiy Storchaka
11.09.13 16:50, Stephen J. Turnbull написав(ла): Which modules in the stdlib would benefit from rewriting using "transformdict"? How about on PyPI? At least _threading_local, cProfile, doctest, json, and perhaps future implementations of __sizeof__ for some classes would benefit from rewriti

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Victor Stinner
2013/9/11 Ethan Furman : > He isn't keeping the key unchanged (notice no white space in MAPPING), he's > merely providing a function that will automatically strip the whitespace > from key lookups. transformdict keeps the key unchanged, see the first message: >>> d = transformdict(str.lower)

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Antoine Pitrou
Le Wed, 11 Sep 2013 07:48:56 -0700, Ethan Furman a écrit : > On 09/11/2013 06:58 AM, Victor Stinner wrote: > > > > The os.environ mapping uses a subclass of MutableMapping which > > accepts 4 functions: encoder/decoder for the key and encoder/decoder > > for the value. Such type is even more gener

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Ethan Furman
On 09/11/2013 08:48 AM, Antoine Pitrou wrote: Le Wed, 11 Sep 2013 07:48:56 -0700, Ethan Furman a écrit : Personally, I wouldn't mind having all four; for one thing, the name 'transformdict' would then be entirely appropriate. ;) The key decoder function is quite useless since the original k

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Ethan Furman
On 09/11/2013 08:49 AM, Victor Stinner wrote: 2013/9/11 Ethan Furman : He isn't keeping the key unchanged (notice no white space in MAPPING), he's merely providing a function that will automatically strip the whitespace from key lookups. transformdict keeps the key unchanged, see the first mes

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Ethan Furman
On 09/11/2013 06:58 AM, Victor Stinner wrote: The os.environ mapping uses a subclass of MutableMapping which accepts 4 functions: encoder/decoder for the key and encoder/decoder for the value. Such type is even more generic. transformdict cannot replace os._Environ. True, it's more generic --

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Ethan Furman
On 09/11/2013 06:58 AM, Victor Stinner wrote: 2013/9/11 Steven D'Aprano : But the proposal is not for a case-insensitive dict. It is more general than that, with case-insensitivity just one specific use-case for such a transformative dict. Arguably the most natural, or at least obvious, such tra

Re: [Python-Dev] importance of dir

2013-09-11 Thread Skip Montanaro
>> Note: Because dir() is supplied primarily as a convenience for >> use at an interactive prompt [...] This was always my interpretation of its intent. In fact, I use a customized dir() for my own needs which would probably break inspect (elides _-prefixed functions by default, notes modules or

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Ethan Furman
On 09/11/2013 02:38 AM, Serhiy Storchaka wrote: There is a question about specifying the transform function. There are three ways to do this: 1. Positional argument of the constructor. d = TransformDict(str.casefold, Foo=5) This method follows the precedent of defaultdict: --> from collecti

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Ethan Furman
On 09/11/2013 05:47 AM, Nick Coghlan wrote: On 11 September 2013 21:57, R. David Murray wrote: Except it is wider than that: the transform function can be anything, not just case folding. I suggested surjectiondict or ontodict, but Antoine didn't like those :) (I had to look up the terms...it'

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Antoine Pitrou
Le Wed, 11 Sep 2013 22:50:08 +0900, "Stephen J. Turnbull" a écrit : > Antoine Pitrou writes: > > > ExitStack was quite a new thing, API-wise. The proposal here is to > > generalize something which already exists in various forms all > > over the Internet, and respecting a well-known API, Mutab

[Python-Dev] importance of dir

2013-09-11 Thread Ethan Furman
http://docs.python.org/3/library/functions.html#dir: Note: Because dir() is supplied primarily as a convenience for use at an interactive prompt [...] I suspect this comment is out of date, as there are two functions in the inspect module that rely on dir(), which also means that help indir

Re: [Python-Dev] Need testing audio files

2013-09-11 Thread Barry Warsaw
On Sep 11, 2013, at 01:09 PM, Serhiy Storchaka wrote: >In ideal it should be one high-quality (float64?) multichannel (5+1?) but >short master file and it's lower-quality copies made by third-party tools. In >ideal the content should be related to Python. I have some pro-audio recording capabilit

Re: [Python-Dev] Need testing audio files

2013-09-11 Thread Oleg Broytman
On Wed, Sep 11, 2013 at 09:54:44AM -0400, Brett Cannon wrote: > On Wed, Sep 11, 2013 at 8:46 AM, Victor Stinner > wrote: > And if you don't want your voice in the test suite forever you can see if > you can convince Guido to say "Python" into a microphone. Wouldn't his name be enough? http://

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Victor Stinner
2013/9/11 Steven D'Aprano : > But the proposal is not for a case-insensitive dict. It is more general > than that, with case-insensitivity just one specific use-case for such > a transformative dict. Arguably the most natural, or at least obvious, > such transformation, but there are others. > > I

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Steven D'Aprano
On Wed, Sep 11, 2013 at 10:47:12PM +1000, Nick Coghlan wrote: > I'll join the chorus requesting that this live on PyPI for a while first. Another alternative would be ActiveState's Python recipes: http://code.activestate.com/recipes/langs/python which is a lot lighter weight than creating a pac

Re: [Python-Dev] Need testing audio files

2013-09-11 Thread Brett Cannon
On Wed, Sep 11, 2013 at 8:46 AM, Victor Stinner wrote: > Use your microphone, say "python" and save the file in your favorite > file format. Try for example Audacity. I suppose that you don't need > specific audio content and you don't need a huge file. > And if you don't want your voice in the t

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Stephen J. Turnbull
Antoine Pitrou writes: > ExitStack was quite a new thing, API-wise. The proposal here is to > generalize something which already exists in various forms all over the > Internet, and respecting a well-known API, MutableMapping. What Nick said was "I was too close to the design, and time and a v

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Steven D'Aprano
On Wed, Sep 11, 2013 at 06:08:25AM -0500, Skip Montanaro wrote: > (I still don't care for the name. "Transform" != "case folding" in my > mind. A quick scan of your links suggests most people think something > like "cidict" or "CaseInsensitiveDict" would be more descriptive.) But the proposal is

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Antoine Pitrou
Le Wed, 11 Sep 2013 22:47:12 +1000, Nick Coghlan a écrit : > > I'll join the chorus requesting that this live on PyPI for a while > first. > > I think this is a case similar to what happened with > contextlib.ExitStack: I'm not sure if anyone actually *used* > contextlib2 for anything significan

Re: [Python-Dev] Need testing audio files

2013-09-11 Thread Victor Stinner
Use your microphone, say "python" and save the file in your favorite file format. Try for example Audacity. I suppose that you don't need specific audio content and you don't need a huge file. Victor 2013/9/11 Serhiy Storchaka : > I work on enhancement of audio modules testing [1], and I need fre

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Nick Coghlan
On 11 September 2013 21:57, R. David Murray wrote: > Except it is wider than that: the transform function can be anything, > not just case folding. > > I suggested surjectiondict or ontodict, but Antoine didn't like those :) > (I had to look up the terms...it's been a long time since I studied > m

Re: [Python-Dev] Need testing audio files

2013-09-11 Thread Antoine Pitrou
Le Wed, 11 Sep 2013 13:09:36 +0300, Serhiy Storchaka a écrit : > I work on enhancement of audio modules testing [1], and I need free > (in both senses) small sample audio files in different formats. We > already have audiotest.au (mono, and sunau has a bug in processing > multichannel files [2]) a

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread R. David Murray
On Wed, 11 Sep 2013 06:08:25 -0500, Skip Montanaro wrote: > > Seriously, I'm curious: what needs to mature, according to you? > > In my mind, its availability on PyPI along with demonstrated use in > the wild (plus corresponding votes to demonstrate that people use/like > it) would help. That yo

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Serhiy Storchaka
11.09.13 14:07, Antoine Pitrou написав(ла): But I don't think the "type generator" API would be easier to implement in C, anyway. No, I mean subclassing approach. ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/list

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Skip Montanaro
> Seriously, I'm curious: what needs to mature, according to you? In my mind, its availability on PyPI along with demonstrated use in the wild (plus corresponding votes to demonstrate that people use/like it) would help. That you can find several implementations at this doesn't mean it's necessar

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Antoine Pitrou
Le Wed, 11 Sep 2013 13:37:53 +0300, Serhiy Storchaka a écrit : > > Actually the defaultdict is just simple wrapper around existing > functionality of the __missing__ method. We can add the __transform__ > method directly in the dict class. I think it will significant (2-3x) > decrease a size o

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Serhiy Storchaka
11.09.13 12:52, Antoine Pitrou написав(ла): Le Wed, 11 Sep 2013 12:38:13 +0300, Serhiy Storchaka a écrit : 2. Subclassing. class CaseInsensitiveDict(TransformDict): def transform(self, key): return key.casefold() d = CaseInsensitiveDict(Foo=5) I thought about this first, and

[Python-Dev] Need testing audio files

2013-09-11 Thread Serhiy Storchaka
I work on enhancement of audio modules testing [1], and I need free (in both senses) small sample audio files in different formats. We already have audiotest.au (mono, and sunau has a bug in processing multichannel files [2]) and Sine-1000Hz-300ms.aif, but this is not enough. I have generated a

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Antoine Pitrou
Le Wed, 11 Sep 2013 12:38:13 +0300, Serhiy Storchaka a écrit : > 2. Subclassing. > > class CaseInsensitiveDict(TransformDict): > def transform(self, key): > return key.casefold() > d = CaseInsensitiveDict(Foo=5) I thought about this first, and then I remembered that python-dev isn'

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Serhiy Storchaka
There is a question about specifying the transform function. There are three ways to do this: 1. Positional argument of the constructor. d = TransformDict(str.casefold, Foo=5) 2. Subclassing. class CaseInsensitiveDict(TransformDict): def transform(self, key): return key.casefold()

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Antoine Pitrou
Le Tue, 10 Sep 2013 21:40:36 -0500, Raymond Hettinger a écrit : > > On Sep 10, 2013, at 4:28 AM, Antoine Pitrou > wrote: > > > In http://bugs.python.org/issue18986 I proposed adding a new mapping > > type to the collections module. > > I would *really* like for this to start outside the standa