syntax difference

Antoon Pardon antoon.pardon at vub.be
Tue Jun 26 09:48:00 EDT 2018


On 26-06-18 14:47, Bart wrote:
>
> [About bitsets]
>
> Here's the set of characters allowed in a C identifier (not using
> Python syntax):
>
>   cident = {'A'..'Z', 'a'..'z', '0'..'9', '_', '9'}
>
> The characters allowed in a hex constant:
>
>   {'0'..'9', 'A'..'F', 'a'..'f'}
>
> A set representing every Unicode character, except those which can be
> C identifiers:
>
>   {0..1_114_111} - cident
>
> The latter taking only 136KB rather than 64MB as it seemed to.
>
> I don't know whether there is a direct equivalent in Python (I thought
> somebody would point it out), apart from ways to construct similar
> functionality with bit-arrays (but then, every language can have such
> sets if you take the DIY approach).

Well that is technically correct but not the whole story. Few languages allow you to
blend in your DIY approach, so that from a users perspective it makes little difference
whether the datatype was provided by the language or the result of a DIY approach.

So if you want your bitsets, it isn't hard to provide them and you can use them like
ordinary python sets. I think that is a big positive point for a language.

-- 
Antoon Pardon





More information about the Python-list mailing list