Re: [Python-ideas] Implement `itertools.permutations.__getitem__` and `itertools.permutations.index`

Hi guys,
I just wanted to give an update on this: I just released my own code that does this to PyPI: https://pypi.python.org/pypi/combi
Thanks, Ram.
On Tue, Jun 10, 2014 at 9:24 AM, Ram Rachum ram@rachum.com wrote:
I'll email you if/when it's released :)
On Tue, Jun 10, 2014 at 9:04 AM, Neil Girdhar mistersheik@gmail.com wrote:
I really like this and hope that it eventually makes it into the stdlib. It's also a good argument for your other suggestion whereby some of the itertools to return Iterables rather than Iterators like range does.
Best,
Neil
On Wednesday, May 7, 2014 1:43:20 PM UTC-4, Ram Rachum wrote:
I'm probably going to implement it in my python_toolbox package. I already implemented 30% and it's really cool. It's at the point where I doubt that I want it in the stdlib because I've gotten so much awesome functionality into it and I'd hate to (a) have 80% of it stripped and (b) have the class names changed to be non-Pythonic :)
On Wed, May 7, 2014 at 8:40 PM, Tal Einat tale...@gmail.com wrote:
On Wed, May 7, 2014 at 8:21 PM, Ram Rachum ram.r...@gmail.com wrote:
Hi Tal,
I'm using it for a project of my own (optimizing keyboard layout) but
I
can't make the case that it's useful for the stdlib. I'd understand
if it
would be omitted for not being enough of a common need.
At the least, this (a function for getting a specific permutation by lexicographical-order index) could make a nice cookbook recipe.
- Tal
Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/ --
You received this message because you are subscribed to a topic in the Google Groups "python-ideas" group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-ideas/in2gUQMFUzA/unsubscribe. To unsubscribe from this group and all its topics, send an email to python-ideas+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout.

Looks great!
Why did you go with "get_rapplied", "unrapplied", etc. instead of having a copy() method and using settable properties?
On Mon, Nov 17, 2014 at 10:50 AM, Ram Rachum ram@rachum.com wrote:
Hi guys,
I just wanted to give an update on this: I just released my own code that does this to PyPI: https://pypi.python.org/pypi/combi
Thanks, Ram.
On Tue, Jun 10, 2014 at 9:24 AM, Ram Rachum ram@rachum.com wrote:
I'll email you if/when it's released :)
On Tue, Jun 10, 2014 at 9:04 AM, Neil Girdhar mistersheik@gmail.com wrote:
I really like this and hope that it eventually makes it into the stdlib. It's also a good argument for your other suggestion whereby some of the itertools to return Iterables rather than Iterators like range does.
Best,
Neil
On Wednesday, May 7, 2014 1:43:20 PM UTC-4, Ram Rachum wrote:
I'm probably going to implement it in my python_toolbox package. I already implemented 30% and it's really cool. It's at the point where I doubt that I want it in the stdlib because I've gotten so much awesome functionality into it and I'd hate to (a) have 80% of it stripped and (b) have the class names changed to be non-Pythonic :)
On Wed, May 7, 2014 at 8:40 PM, Tal Einat tale...@gmail.com wrote:
On Wed, May 7, 2014 at 8:21 PM, Ram Rachum ram.r...@gmail.com wrote:
Hi Tal,
I'm using it for a project of my own (optimizing keyboard layout)
but I
can't make the case that it's useful for the stdlib. I'd understand
if it
would be omitted for not being enough of a common need.
At the least, this (a function for getting a specific permutation by lexicographical-order index) could make a nice cookbook recipe.
- Tal
Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/ --
You received this message because you are subscribed to a topic in the Google Groups "python-ideas" group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-ideas/in2gUQMFUzA/unsubscribe. To unsubscribe from this group and all its topics, send an email to python-ideas+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout.

Thanks :)
Settable properties are a no-go because I wanted permutation spaces to be immutable. Since the cost of creating a new space is nil (permutations are created on-demand, not on space creation) there isn't a reason to mutate an existing space.
I don't think using a copy() method to would be very nice. But I guess it's a matter of taste.
On Mon, Nov 17, 2014 at 7:33 PM, Neil Girdhar mistersheik@gmail.com wrote:
Looks great!
Why did you go with "get_rapplied", "unrapplied", etc. instead of having a copy() method and using settable properties?
On Mon, Nov 17, 2014 at 10:50 AM, Ram Rachum ram@rachum.com wrote:
Hi guys,
I just wanted to give an update on this: I just released my own code that does this to PyPI: https://pypi.python.org/pypi/combi
Thanks, Ram.
On Tue, Jun 10, 2014 at 9:24 AM, Ram Rachum ram@rachum.com wrote:
I'll email you if/when it's released :)
On Tue, Jun 10, 2014 at 9:04 AM, Neil Girdhar mistersheik@gmail.com wrote:
I really like this and hope that it eventually makes it into the stdlib. It's also a good argument for your other suggestion whereby some of the itertools to return Iterables rather than Iterators like range does.
Best,
Neil
On Wednesday, May 7, 2014 1:43:20 PM UTC-4, Ram Rachum wrote:
I'm probably going to implement it in my python_toolbox package. I already implemented 30% and it's really cool. It's at the point where I doubt that I want it in the stdlib because I've gotten so much awesome functionality into it and I'd hate to (a) have 80% of it stripped and (b) have the class names changed to be non-Pythonic :)
On Wed, May 7, 2014 at 8:40 PM, Tal Einat tale...@gmail.com wrote:
On Wed, May 7, 2014 at 8:21 PM, Ram Rachum ram.r...@gmail.com wrote:
> Hi Tal, > > I'm using it for a project of my own (optimizing keyboard layout) but I > can't make the case that it's useful for the stdlib. I'd understand if it > would be omitted for not being enough of a common need.
At the least, this (a function for getting a specific permutation by lexicographical-order index) could make a nice cookbook recipe.
- Tal
Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/ --
You received this message because you are subscribed to a topic in the Google Groups "python-ideas" group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-ideas/in2gUQMFUzA/unsubscribe. To unsubscribe from this group and all its topics, send an email to python-ideas+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout.

Sure, but even list has copy(). I meant settable property on the generator not on the generated permutation.
On Mon, Nov 17, 2014 at 12:44 PM, Ram Rachum ram@rachum.com wrote:
Thanks :)
Settable properties are a no-go because I wanted permutation spaces to be immutable. Since the cost of creating a new space is nil (permutations are created on-demand, not on space creation) there isn't a reason to mutate an existing space.
I don't think using a copy() method to would be very nice. But I guess it's a matter of taste.
On Mon, Nov 17, 2014 at 7:33 PM, Neil Girdhar mistersheik@gmail.com wrote:
Looks great!
Why did you go with "get_rapplied", "unrapplied", etc. instead of having a copy() method and using settable properties?
On Mon, Nov 17, 2014 at 10:50 AM, Ram Rachum ram@rachum.com wrote:
Hi guys,
I just wanted to give an update on this: I just released my own code that does this to PyPI: https://pypi.python.org/pypi/combi
Thanks, Ram.
On Tue, Jun 10, 2014 at 9:24 AM, Ram Rachum ram@rachum.com wrote:
I'll email you if/when it's released :)
On Tue, Jun 10, 2014 at 9:04 AM, Neil Girdhar mistersheik@gmail.com wrote:
I really like this and hope that it eventually makes it into the stdlib. It's also a good argument for your other suggestion whereby some of the itertools to return Iterables rather than Iterators like range does.
Best,
Neil
On Wednesday, May 7, 2014 1:43:20 PM UTC-4, Ram Rachum wrote:
I'm probably going to implement it in my python_toolbox package. I already implemented 30% and it's really cool. It's at the point where I doubt that I want it in the stdlib because I've gotten so much awesome functionality into it and I'd hate to (a) have 80% of it stripped and (b) have the class names changed to be non-Pythonic :)
On Wed, May 7, 2014 at 8:40 PM, Tal Einat tale...@gmail.com wrote:
On Wed, May 7, 2014 at 8:21 PM, Ram Rachum ram.r...@gmail.com > wrote: > > Hi Tal, > > > > I'm using it for a project of my own (optimizing keyboard layout) > but I > > can't make the case that it's useful for the stdlib. I'd > understand if it > > would be omitted for not being enough of a common need. > > At the least, this (a function for getting a specific permutation by > lexicographical-order index) could make a nice cookbook recipe. > > - Tal >
Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/ --
You received this message because you are subscribed to a topic in the Google Groups "python-ideas" group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-ideas/in2gUQMFUzA/unsubscribe . To unsubscribe from this group and all its topics, send an email to python-ideas+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout.

I'm not sure what you mean. Can you please give an example?
On Mon, Nov 17, 2014 at 8:01 PM, Neil Girdhar mistersheik@gmail.com wrote:
Sure, but even list has copy(). I meant settable property on the generator not on the generated permutation.
On Mon, Nov 17, 2014 at 12:44 PM, Ram Rachum ram@rachum.com wrote:
Thanks :)
Settable properties are a no-go because I wanted permutation spaces to be immutable. Since the cost of creating a new space is nil (permutations are created on-demand, not on space creation) there isn't a reason to mutate an existing space.
I don't think using a copy() method to would be very nice. But I guess it's a matter of taste.
On Mon, Nov 17, 2014 at 7:33 PM, Neil Girdhar mistersheik@gmail.com wrote:
Looks great!
Why did you go with "get_rapplied", "unrapplied", etc. instead of having a copy() method and using settable properties?
On Mon, Nov 17, 2014 at 10:50 AM, Ram Rachum ram@rachum.com wrote:
Hi guys,
I just wanted to give an update on this: I just released my own code that does this to PyPI: https://pypi.python.org/pypi/combi
Thanks, Ram.
On Tue, Jun 10, 2014 at 9:24 AM, Ram Rachum ram@rachum.com wrote:
I'll email you if/when it's released :)
On Tue, Jun 10, 2014 at 9:04 AM, Neil Girdhar mistersheik@gmail.com wrote:
I really like this and hope that it eventually makes it into the stdlib. It's also a good argument for your other suggestion whereby some of the itertools to return Iterables rather than Iterators like range does.
Best,
Neil
On Wednesday, May 7, 2014 1:43:20 PM UTC-4, Ram Rachum wrote:
> I'm probably going to implement it in my python_toolbox package. I > already implemented 30% and it's really cool. It's at the point where I > doubt that I want it in the stdlib because I've gotten so much awesome > functionality into it and I'd hate to (a) have 80% of it stripped and (b) > have the class names changed to be non-Pythonic :) > > > On Wed, May 7, 2014 at 8:40 PM, Tal Einat tale...@gmail.com wrote: > > On Wed, May 7, 2014 at 8:21 PM, Ram Rachum ram.r...@gmail.com >> wrote: >> > Hi Tal, >> > >> > I'm using it for a project of my own (optimizing keyboard layout) >> but I >> > can't make the case that it's useful for the stdlib. I'd >> understand if it >> > would be omitted for not being enough of a common need. >> >> At the least, this (a function for getting a specific permutation by >> lexicographical-order index) could make a nice cookbook recipe. >> >> - Tal >> > > _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/ --
You received this message because you are subscribed to a topic in the Google Groups "python-ideas" group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-ideas/in2gUQMFUzA/unsubscribe . To unsubscribe from this group and all its topics, send an email to python-ideas+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout.

perm_space = PermSpace(3)
perm_space.degrees = 3
list(perm_space)
perm_space.degrees = None
list(perm_space)
etc.
On Mon, Nov 17, 2014 at 2:37 PM, Ram Rachum ram@rachum.com wrote:
I'm not sure what you mean. Can you please give an example?
On Mon, Nov 17, 2014 at 8:01 PM, Neil Girdhar mistersheik@gmail.com wrote:
Sure, but even list has copy(). I meant settable property on the generator not on the generated permutation.
On Mon, Nov 17, 2014 at 12:44 PM, Ram Rachum ram@rachum.com wrote:
Thanks :)
Settable properties are a no-go because I wanted permutation spaces to be immutable. Since the cost of creating a new space is nil (permutations are created on-demand, not on space creation) there isn't a reason to mutate an existing space.
I don't think using a copy() method to would be very nice. But I guess it's a matter of taste.
On Mon, Nov 17, 2014 at 7:33 PM, Neil Girdhar mistersheik@gmail.com wrote:
Looks great!
Why did you go with "get_rapplied", "unrapplied", etc. instead of having a copy() method and using settable properties?
On Mon, Nov 17, 2014 at 10:50 AM, Ram Rachum ram@rachum.com wrote:
Hi guys,
I just wanted to give an update on this: I just released my own code that does this to PyPI: https://pypi.python.org/pypi/combi
Thanks, Ram.
On Tue, Jun 10, 2014 at 9:24 AM, Ram Rachum ram@rachum.com wrote:
I'll email you if/when it's released :)
On Tue, Jun 10, 2014 at 9:04 AM, Neil Girdhar mistersheik@gmail.com wrote:
> I really like this and hope that it eventually makes it into the > stdlib. It's also a good argument for your other suggestion whereby some > of the itertools to return Iterables rather than Iterators like range does. > > Best, > > Neil > > On Wednesday, May 7, 2014 1:43:20 PM UTC-4, Ram Rachum wrote: > >> I'm probably going to implement it in my python_toolbox package. I >> already implemented 30% and it's really cool. It's at the point where I >> doubt that I want it in the stdlib because I've gotten so much awesome >> functionality into it and I'd hate to (a) have 80% of it stripped and (b) >> have the class names changed to be non-Pythonic :) >> >> >> On Wed, May 7, 2014 at 8:40 PM, Tal Einat tale...@gmail.com >> wrote: >> >> On Wed, May 7, 2014 at 8:21 PM, Ram Rachum ram.r...@gmail.com >>> wrote: >>> > Hi Tal, >>> > >>> > I'm using it for a project of my own (optimizing keyboard >>> layout) but I >>> > can't make the case that it's useful for the stdlib. I'd >>> understand if it >>> > would be omitted for not being enough of a common need. >>> >>> At the least, this (a function for getting a specific permutation >>> by >>> lexicographical-order index) could make a nice cookbook recipe. >>> >>> - Tal >>> >> >> > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- > > --- > You received this message because you are subscribed to a topic in > the Google Groups "python-ideas" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/python-ideas/in2gUQMFUzA/unsubscribe > . > To unsubscribe from this group and all its topics, send an email to > python-ideas+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > >

Ah, I understand. I don't like it, though I'm not sure I can really express why. One reason is that this would mean that PermSpaces would be mutable, and thus not hashable and not usable as keys in dicts and sets. It would also mean I couldn't use the `CachedProperty` pattern all over the class as I do today. So these are a couple of reasons, there might be more that didn't come to me now.
On Mon, Nov 17, 2014 at 9:40 PM, Neil Girdhar mistersheik@gmail.com wrote:
perm_space = PermSpace(3)
perm_space.degrees = 3
list(perm_space)
perm_space.degrees = None
list(perm_space)
etc.
On Mon, Nov 17, 2014 at 2:37 PM, Ram Rachum ram@rachum.com wrote:
I'm not sure what you mean. Can you please give an example?
On Mon, Nov 17, 2014 at 8:01 PM, Neil Girdhar mistersheik@gmail.com wrote:
Sure, but even list has copy(). I meant settable property on the generator not on the generated permutation.
On Mon, Nov 17, 2014 at 12:44 PM, Ram Rachum ram@rachum.com wrote:
Thanks :)
Settable properties are a no-go because I wanted permutation spaces to be immutable. Since the cost of creating a new space is nil (permutations are created on-demand, not on space creation) there isn't a reason to mutate an existing space.
I don't think using a copy() method to would be very nice. But I guess it's a matter of taste.
On Mon, Nov 17, 2014 at 7:33 PM, Neil Girdhar mistersheik@gmail.com wrote:
Looks great!
Why did you go with "get_rapplied", "unrapplied", etc. instead of having a copy() method and using settable properties?
On Mon, Nov 17, 2014 at 10:50 AM, Ram Rachum ram@rachum.com wrote:
Hi guys,
I just wanted to give an update on this: I just released my own code that does this to PyPI: https://pypi.python.org/pypi/combi
Thanks, Ram.
On Tue, Jun 10, 2014 at 9:24 AM, Ram Rachum ram@rachum.com wrote:
> I'll email you if/when it's released :) > > > On Tue, Jun 10, 2014 at 9:04 AM, Neil Girdhar <mistersheik@gmail.com > > wrote: > >> I really like this and hope that it eventually makes it into the >> stdlib. It's also a good argument for your other suggestion whereby some >> of the itertools to return Iterables rather than Iterators like range does. >> >> Best, >> >> Neil >> >> On Wednesday, May 7, 2014 1:43:20 PM UTC-4, Ram Rachum wrote: >> >>> I'm probably going to implement it in my python_toolbox package. I >>> already implemented 30% and it's really cool. It's at the point where I >>> doubt that I want it in the stdlib because I've gotten so much awesome >>> functionality into it and I'd hate to (a) have 80% of it stripped and (b) >>> have the class names changed to be non-Pythonic :) >>> >>> >>> On Wed, May 7, 2014 at 8:40 PM, Tal Einat tale...@gmail.com >>> wrote: >>> >>> On Wed, May 7, 2014 at 8:21 PM, Ram Rachum ram.r...@gmail.com >>>> wrote: >>>> > Hi Tal, >>>> > >>>> > I'm using it for a project of my own (optimizing keyboard >>>> layout) but I >>>> > can't make the case that it's useful for the stdlib. I'd >>>> understand if it >>>> > would be omitted for not being enough of a common need. >>>> >>>> At the least, this (a function for getting a specific permutation >>>> by >>>> lexicographical-order index) could make a nice cookbook recipe. >>>> >>>> - Tal >>>> >>> >>> >> _______________________________________________ >> Python-ideas mailing list >> Python-ideas@python.org >> https://mail.python.org/mailman/listinfo/python-ideas >> Code of Conduct: http://python.org/psf/codeofconduct/ >> -- >> >> --- >> You received this message because you are subscribed to a topic in >> the Google Groups "python-ideas" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/python-ideas/in2gUQMFUzA/unsubscribe >> . >> To unsubscribe from this group and all its topics, send an email to >> python-ideas+unsubscribe@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> >> >

Those are good reasons, thanks. :)

On Mon, Nov 17, 2014 at 09:57:55PM +0200, Ram Rachum wrote:
Ah, I understand. I don't like it, though I'm not sure I can really express why. One reason is that this would mean that PermSpaces would be mutable, and thus not hashable and not usable as keys in dicts and sets.
I'm having trouble thinking of any reason to use a PermSpace as a dict key or set element. Do you have a concrete example of doing so?

I actually did that in the project I made Combi for. I had a bunch of perm spaces that signified certain configurations (can't get more specific, sorry) and I wanted to find the best configuration in each space. So I had a dict from each space to the best configuration in that space.
On Tue, Nov 18, 2014 at 1:05 AM, Steven D'Aprano steve@pearwood.info wrote:
On Mon, Nov 17, 2014 at 09:57:55PM +0200, Ram Rachum wrote:
Ah, I understand. I don't like it, though I'm not sure I can really
express
why. One reason is that this would mean that PermSpaces would be mutable, and thus not hashable and not usable as keys in dicts and sets.
I'm having trouble thinking of any reason to use a PermSpace as a dict key or set element. Do you have a concrete example of doing so?
-- Steven _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
participants (3)
-
Neil Girdhar
-
Ram Rachum
-
Steven D'Aprano