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:

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:

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:

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:

Those are good reasons, thanks. :)

On Mon, Nov 17, 2014 at 09:57:55PM +0200, Ram Rachum wrote:
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

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:

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:

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:

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:

Those are good reasons, thanks. :)

On Mon, Nov 17, 2014 at 09:57:55PM +0200, Ram Rachum wrote:
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

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:
participants (3)
-
Neil Girdhar
-
Ram Rachum
-
Steven D'Aprano