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

Ram Rachum ram at rachum.com
Mon Nov 17 20:57:55 CET 2014


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 at 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 at 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 at 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 at 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 at 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 at 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 at rachum.com> wrote:
>>>>>>
>>>>>>> I'll email you if/when it's released :)
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Jun 10, 2014 at 9:04 AM, Neil Girdhar <mistersheik at 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... at gmail.com>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> On Wed, May 7, 2014 at 8:21 PM, Ram Rachum <ram.r... at 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 at 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 at googlegroups.com.
>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20141117/0f2b6120/attachment-0001.html>


More information about the Python-ideas mailing list