Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2018-01-03 Thread Guido van Rossum
On Wed, Jan 3, 2018 at 8:24 AM, Random832 wrote: > On Sun, Dec 31, 2017, at 00:33, Guido van Rossum wrote: > > I'm not keen on this recommendation. An argument that takes a Set[Foo] > > would mean that in order to specify: > > - no flags: you'd have to pass set() -- you

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2018-01-03 Thread Random832
On Sun, Dec 31, 2017, at 00:33, Guido van Rossum wrote: > I'm not keen on this recommendation. An argument that takes a Set[Foo] > would mean that in order to specify: > - no flags: you'd have to pass set() -- you can't use {} since that's an > empty dict, not an empty set Optional[Set[Foo]]? >

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2018-01-01 Thread Guido van Rossum
The enum.Flag type solves all this neatly. On Mon, Jan 1, 2018 at 2:43 PM, Barry Scott wrote: > I'm guessing that what this thread is about is coming up with an API rule > that makes > providing a set of boolean options available to a function or class in the > least

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2018-01-01 Thread Barry Scott
I'm guessing that what this thread is about is coming up with an API rule that makes providing a set of boolean options available to a function or class in the least error prone way. Its the error prone nature of integer bit masks that is behind the enum suggestion I assume. >From the C

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-31 Thread Franklin? Lee
On Sun, Dec 31, 2017 at 12:09 PM, MRAB wrote: > On 2017-12-31 08:13, Paddy3118 wrote: >> >> Hmm, yea I had not thought of how it would look - I had thought formost of >> not needing to necessarily learn about bitsets.when learning about passing a >> large number of

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-31 Thread MRAB
On 2017-12-31 08:13, Paddy3118 wrote: Hmm, yea I had not thought of how it would look - I had thought formost of not needing to necessarily learn about bitsets.when learning about passing a large number of optional flags to a function. Although the default could be None, interpreted as an

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-31 Thread Paddy3118
Hmm, yea I had not thought of how it would look - I had thought formost of not needing to necessarily learn about bitsets.when learning about passing a large number of optional flags to a function. Although the default could be None, interpreted as an empty set of zero values.; a set of one or

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-30 Thread Guido van Rossum
I should probably clarify that for this to work, Foo must derive from enum.Flags. See https://docs.python.org/3/library/enum.html#flag. (Or enum.IntFlag, https://docs.python.org/3/library/enum.html#intflag.) Note that when using Flag, you can name the "zero" value (Color.BLACK in the 3rd

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-30 Thread Guido van Rossum
On Sat, Dec 30, 2017 at 8:50 PM, Franklin? Lee < leewangzhong+pyt...@gmail.com> wrote: > > Paddy might want something like this: > - For existing APIs which take int or IntFlag flags, allow them to > also take a set (or perhaps any collection) of flags. > - In new APIs, take sets of Enum flags,

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-30 Thread Franklin? Lee
On Fri, Dec 29, 2017 at 11:25 PM, Steven D'Aprano wrote: > On Sat, Dec 30, 2017 at 02:56:46AM +1100, Chris Angelico wrote: >> On Sat, Dec 30, 2017 at 2:38 AM, Steven D'Aprano wrote: >> > The lack of support for the `in` operator is a major difference,

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-29 Thread Steven D'Aprano
On Sat, Dec 30, 2017 at 02:56:46AM +1100, Chris Angelico wrote: > On Sat, Dec 30, 2017 at 2:38 AM, Steven D'Aprano wrote: > > The lack of support for the `in` operator is a major difference, but > > there's also `len` (equivalent to "count the one bits"), superset > > and

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-29 Thread Chris Angelico
On Sat, Dec 30, 2017 at 3:56 AM, Stephan Hoyer wrote: > We already have a built-in immutable set for Python. It's called frozenset. This is true, but AIUI its API is based primarily on that of the (mutable) set. If you were creating a greenfield ImmutableSet class, what would

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-29 Thread Stephan Hoyer
We already have a built-in immutable set for Python. It's called frozenset. On Fri, Dec 29, 2017 at 10:56 AM Chris Angelico wrote: > On Sat, Dec 30, 2017 at 2:38 AM, Steven D'Aprano > wrote: > > The lack of support for the `in` operator is a major

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-29 Thread Chris Angelico
On Sat, Dec 30, 2017 at 2:38 AM, Steven D'Aprano wrote: > The lack of support for the `in` operator is a major difference, but > there's also `len` (equivalent to "count the one bits"), superset > and subset testing, various in-place mutator methods, etc. Java has a > BitSet

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-29 Thread Steven D'Aprano
On Fri, Dec 29, 2017 at 10:26:22PM +1100, Chris Angelico wrote: > On Fri, Dec 29, 2017 at 7:18 PM, Steven D'Aprano wrote: > > Since ints don't provide a set-like interface, they aren't strictly > > speaking bitsets. But in any case, nobody is stopping people from using > >

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-29 Thread Chris Angelico
On Fri, Dec 29, 2017 at 7:18 PM, Steven D'Aprano wrote: > Since ints don't provide a set-like interface, they aren't strictly > speaking bitsets. But in any case, nobody is stopping people from using > sets of enum values. I'm not sure what "set-like interface" you'd be

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-29 Thread Steven D'Aprano
On Thu, Dec 28, 2017 at 12:23:53PM -0800, Paddy3118 wrote: > Hi Steve, I did not write an attack on the "Python devs". I didn't say you attacked anyone and your implication that I did is unfair. > Re-read my > original with a little less hostility and there should be room for an >

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-28 Thread Paddy3118
Hi Inada, can I take your point as being that execution speed is an issue? I am coming from the "Python as higher level, more programmer-centric language"direction. In the past, useful but slow things have spurred actions to speed them up. ___

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-28 Thread Paddy3118
Hi Steve, I did not write an attack on the "Python devs". Re-read my original with a little less hostility and there should be room for an interpretation, (which I meant), that does not warrant such a hostile reply. The original is written in the hope of furthering discussion on the need for

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-26 Thread Steven D'Aprano
On Tue, Dec 26, 2017 at 12:07:52PM -0800, Paddy3118 wrote: > Maybe it is time to deemphasize the creation and passing of what is, in > effect, bit-sets as a single > argument, and instead promote the passing of a set of members of an > enum.Enum

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-26 Thread Neil Girdhar
Wouldn't it be more pythonic to just pass flags to re.compile as Boolean keyword arguments? On Tuesday, December 26, 2017 at 3:07:52 PM UTC-5, Paddy3118 wrote: > > Maybe it is time to deemphasize the creation and passing of what is, in > effect, bit-sets

[Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-26 Thread Paddy3118
Maybe it is time to deemphasize the creation and passing of what is, in effect, bit-sets as a single argument, and instead promote the passing of a set of members of an enum.Enum constants. Thi comes about