[Python-Dev] Re: name for new Enum decorator
On Thu, 2021-05-27 at 20:24 -0700, Ethan Furman wrote: > Greetings! > > The Flag type in the enum module has had some improvements, but I find it > necessary to move one of those improvements > into a decorator instead, and I'm having a hard time thinking up a name. > > What is the behavior? Well, a name in a flag type can be either canonical > (it represents one thing), or aliased (it > represents two or more things). To use Color as an example: > > class Color(Flag): > RED = 1# 0001 > GREEN = 2 # 0010 > BLUE = 4 # 0100 > PURPLE = RED | BLUE# 0101 > WHITE = RED | GREEN | BLUE # 0111 > > The flags RED, GREEN, and BLUE are all canonical, while PURPLE and WHITE are > aliases for certain flag combinations. But > what if we have something like: > > class Color(Flag): > RED = 1# 0001 > BLUE = 4 # 0100 > WHITE = 7 # 0111 > > As you see, WHITE is an "alias" for a value that does not exist in the Flag > (0010, or 2). That seems like it's probably > an error. But what about this? > > class FlagWithMasks(IntFlag): > DEFAULT = 0x0 > > FIRST_MASK = 0xF > FIRST_ROUND = 0x0 > FIRST_CEIL = 0x1 > FIRST_TRUNC = 0x2 > > SECOND_MASK = 0xF0 > SECOND_RECALC = 0x00 > SECOND_NO_RECALC = 0x10 > > THIRD_MASK = 0xF00 > THIRD_DISCARD = 0x000 > THIRD_KEEP = 0x100 > > Here we have three flags (FIRST_MASK, SECOND_MASK, THIRD_MASK) that are > aliasing values that don't exist, but it seems > intentional and not an error. > > So, like the enum.unique decorator that can be used when duplicate names > should be an error, I'm adding a new decorator > to verify that a Flag has no missing aliased values that can be used when the > programmer thinks it's appropriate... but > I have no idea what to call it. > > Any nominations? > Maybe something like the following would be a good starting point: @bitmask_require_individual_bits -- Best regards, Michał Górny ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/PPPCZGMDH47UPGH6RKVXNQQX3IQ2AMCS/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-Dev] Re: name for new Enum decorator
On 28. 05. 21 5:24, Ethan Furman wrote: Greetings! The Flag type in the enum module has had some improvements, but I find it necessary to move one of those improvements into a decorator instead, and I'm having a hard time thinking up a name. What is the behavior? Well, a name in a flag type can be either canonical (it represents one thing), or aliased (it represents two or more things). To use Color as an example: class Color(Flag): RED = 1 # 0001 GREEN = 2 # 0010 BLUE = 4 # 0100 PURPLE = RED | BLUE # 0101 WHITE = RED | GREEN | BLUE # 0111 The flags RED, GREEN, and BLUE are all canonical, while PURPLE and WHITE are aliases for certain flag combinations. But what if we have something like: class Color(Flag): RED = 1 # 0001 BLUE = 4 # 0100 WHITE = 7 # 0111 As you see, WHITE is an "alias" for a value that does not exist in the Flag (0010, or 2). That seems like it's probably an error. But what about this? class FlagWithMasks(IntFlag): DEFAULT = 0x0 FIRST_MASK = 0xF FIRST_ROUND = 0x0 FIRST_CEIL = 0x1 FIRST_TRUNC = 0x2 SECOND_MASK = 0xF0 SECOND_RECALC = 0x00 SECOND_NO_RECALC = 0x10 THIRD_MASK = 0xF00 THIRD_DISCARD = 0x000 THIRD_KEEP = 0x100 Here we have three flags (FIRST_MASK, SECOND_MASK, THIRD_MASK) that are aliasing values that don't exist, but it seems intentional and not an error. So, like the enum.unique decorator that can be used when duplicate names should be an error, I'm adding a new decorator to verify that a Flag has no missing aliased values that can be used when the programmer thinks it's appropriate... but I have no idea what to call it. Any nominations? Are you looking for a decorator for the whole Enum, or a way to mark individual *values* as masks? ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/NDQ55INDDQMGERVYUHUYNDZ572IPD4UY/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-Dev] Re: name for new Enum decorator
On 5/28/2021 12:08 AM, Michał Górny wrote: On Thu, 2021-05-27 at 20:24 -0700, Ethan Furman wrote: Greetings! The Flag type in the enum module has had some improvements, but I find it necessary to move one of those improvements into a decorator instead, and I'm having a hard time thinking up a name. What is the behavior? Well, a name in a flag type can be either canonical (it represents one thing), or aliased (it represents two or more things). To use Color as an example: class Color(Flag): RED = 1# 0001 GREEN = 2 # 0010 BLUE = 4 # 0100 PURPLE = RED | BLUE# 0101 WHITE = RED | GREEN | BLUE # 0111 The flags RED, GREEN, and BLUE are all canonical, while PURPLE and WHITE are aliases for certain flag combinations. But what if we have something like: class Color(Flag): RED = 1# 0001 BLUE = 4 # 0100 WHITE = 7 # 0111 As you see, WHITE is an "alias" for a value that does not exist in the Flag (0010, or 2). That seems like it's probably an error. But what about this? class FlagWithMasks(IntFlag): DEFAULT = 0x0 FIRST_MASK = 0xF FIRST_ROUND = 0x0 FIRST_CEIL = 0x1 FIRST_TRUNC = 0x2 SECOND_MASK = 0xF0 SECOND_RECALC = 0x00 SECOND_NO_RECALC = 0x10 THIRD_MASK = 0xF00 THIRD_DISCARD = 0x000 THIRD_KEEP = 0x100 Here we have three flags (FIRST_MASK, SECOND_MASK, THIRD_MASK) that are aliasing values that don't exist, but it seems intentional and not an error. So, like the enum.unique decorator that can be used when duplicate names should be an error, I'm adding a new decorator to verify that a Flag has no missing aliased values that can be used when the programmer thinks it's appropriate... but I have no idea what to call it. Any nominations? Maybe something like the following would be a good starting point: @bitmask_require_individual_bits @all_bits_defined or @unique_bits ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/NE5UYXEUZ6KKHVH3Z2OX45SSWCXYEYYO/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-Dev] Need help to debug a ssl crash on Windows which prevents merging PRs
Hi, In the 3.10 branch, it became really hard to merge PRs because the following ssl crashs on Windows: https://bugs.python.org/issue44252 It has a failure rate 1/2 (on average) on the "Windows x86" and "Windows x64" jobs of GitHub Action and on the Win32 and Win64 jobs of the Azure Pipelines. I failed to reproduce it on an up to date Windows 10 with an up to date Visual Studio 2019. I cannot say if it's a race condition, if it's a bug in Python, if it's a bug in the tests (it sounds unlikely, it worked well previously and it's a hard crash, not a Python exception), if it's a bug in the C compiler or in Windows itself... Since there are other random test failures like test_asyncio, it now requires multiple "re-run jobs" on GitHub Actions. Example of test_asyncio test which fails frequently on Windows: https://bugs.python.org/issue41682 If someone can reproduce https://bugs.python.org/issue44252 crash on Windows, can you please provide me a SSH access to your machine so I can debug it? Here is my public SSH key: https://github.com/vstinner.keys Is there a way to get a SSH access to a machine of the GitHub Action CI job or of an Azure Pipelines CI job? Victor -- Night gathers, and now my watch begins. It shall not end until my death. ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/B7DIDGAZWV3WET227Z3LPXI5LUZX2DFP/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-Dev] Summary of Python tracker Issues
ACTIVITY SUMMARY (2021-05-21 - 2021-05-28) Python tracker at https://bugs.python.org/ To view or respond to any of the issues listed below, click on the issue. Do NOT respond to this message. Issues counts and deltas: open7424 (-28) closed 48574 (+82) total 55998 (+54) Open issues with patches: 2945 Issues opened (38) == #44209: urllib.robotparser fail on Disallow: /? from google.com https://bugs.python.org/issue44209 opened by karl.pradene #44210: Make importlib.metadata._meta.PackageMetadata public https://bugs.python.org/issue44210 opened by FFY00 #44211: Duplicate '.bmp' key in mimetypes.py, maps to both 'image/bmp' https://bugs.python.org/issue44211 opened by andreasjansson #44212: asyncio overrides signal handlers https://bugs.python.org/issue44212 opened by Francisco Demartino #44213: LIST_TO_TUPLE placed below the sentence "all of the following https://bugs.python.org/issue44213 opened by glubs9 #44214: PyArg_Parse* for vectorcall? https://bugs.python.org/issue44214 opened by ronaldoussoren #44215: help() module listing displays import warnings from deprecated https://bugs.python.org/issue44215 opened by stefanor #44217: Tkinter/IDLE: literal astral char discombobulates text editing https://bugs.python.org/issue44217 opened by shreyanavigyan #44218: Possible Stack Based Buffer Overflow at Programs/_freeze_impor https://bugs.python.org/issue44218 opened by demonia #44219: Opening a file holds the GIL when it calls "isatty()" https://bugs.python.org/issue44219 opened by smurfix #44220: PyStructSequence_UnnamedField unavailable on Windows https://bugs.python.org/issue44220 opened by johnboy2 #44221: ImportError: sys.meta_path is None, Python is likely shutting https://bugs.python.org/issue44221 opened by luizoti #44225: stop() on a stopped loop inhibits the next run_forever https://bugs.python.org/issue44225 opened by mandolaerik #44226: Threads shutting down in Py 2.7 but not in Py 3.69 while makin https://bugs.python.org/issue44226 opened by muralidhar.bn #44229: Intermittent connection errors in ssl tests on macOS CI https://bugs.python.org/issue44229 opened by erlendaasland #44230: lookup extensions with the stable ABI under a platform specifi https://bugs.python.org/issue44230 opened by doko #44233: Provide Windows Terminal Fragment Extension https://bugs.python.org/issue44233 opened by mveril #44234: Debugging with LLDB doesn't work for universal2 installer on m https://bugs.python.org/issue44234 opened by ronaldoussoren #44235: Remove l*gettext() and related functions in the gettext module https://bugs.python.org/issue44235 opened by corona10 #44236: Define SOABI, LIBRARY, LDLIBRARY and LIBPL on Windows https://bugs.python.org/issue44236 opened by steve.dower #44237: test_ssl randomly fails on macOS GH Action: test_get_server_ce https://bugs.python.org/issue44237 opened by vstinner #44238: Unable to install Python 3.9.5 - Windows Server https://bugs.python.org/issue44238 opened by RFuentes #44239: Use platform defined data directories instead of ~/.python_his https://bugs.python.org/issue44239 opened by oxalica #44240: Incorrect behavior of LOAD_ATTR due to overflow in tp_version https://bugs.python.org/issue44240 opened by Mark.Shannon #44242: enum.IntFlag regression: missing values cause TypeError https://bugs.python.org/issue44242 opened by hroncok #44245: Cross-compilation of CPython 3.8 with _socket module using And https://bugs.python.org/issue44245 opened by laheller #44246: 3.10 beta 1: breaking change in importlib.metadata entry point https://bugs.python.org/issue44246 opened by Anthony Sottile #44249: Readme typo fix https://bugs.python.org/issue44249 opened by Ayushparikh-code #44251: ctypes '_get_soname' fails silently on missing objdump https://bugs.python.org/issue44251 opened by GuillaumeDesforges #44252: test_ssl and test_httplib.HTTPSTest crash randomly with "Windo https://bugs.python.org/issue44252 opened by vstinner #44254: Change turtledemo button colors https://bugs.python.org/issue44254 opened by terry.reedy #44255: strptime and week numbers without week days https://bugs.python.org/issue44255 opened by Jaap van der Velde #44257: typo and verbous grammar in the grammar spec https://bugs.python.org/issue44257 opened by orangebana15 #44258: Support PEP 515 for Fraction's initialization from string https://bugs.python.org/issue44258 opened by Sergey.Kirpichev #44259: lib2to3 does not accept "exec" as name https://bugs.python.org/issue44259 opened by mulugruntz #44260: _Random.seed() is called twice https://bugs.python.org/issue44260 opened by serhiy.storchaka #44261: SocketType documentation misleading https://bugs.python.org/issue44261 opened by srittau #44262: tarfile: some content different output https://bugs.python.org/issue44262 opened by yellowhat Most recent 15 issues with no replies (15) == #44262: tarfile: some
[Python-Dev] Re: name for new Enum decorator
On 5/28/21 12:43 AM, Petr Viktorin wrote: > On 28. 05. 21 5:24, Ethan Furman wrote: >> class FlagWithMasks(IntFlag): >> DEFAULT = 0x0 >> >> FIRST_MASK = 0xF >> FIRST_ROUND = 0x0 >> FIRST_CEIL = 0x1 >> FIRST_TRUNC = 0x2 >> >> SECOND_MASK = 0xF0 >> SECOND_RECALC = 0x00 >> SECOND_NO_RECALC = 0x10 >> >> THIRD_MASK = 0xF00 >> THIRD_DISCARD = 0x000 >> THIRD_KEEP = 0x100 >> >> Here we have three flags (FIRST_MASK, SECOND_MASK, THIRD_MASK) that are aliasing values >> that don't exist, but it seems intentional and not an error. > > Are you looking for a decorator for the whole Enum, or a way to mark individual *values* as masks? The decorator is for whole enum. The issue is not that some values are masks, but whether the absence of named bits covered by the mask is an error. -- ~Ethan~ ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/OM5M774MP5QPLFXZ7OVGBPR7ZFB6X35A/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-Dev] Re: python-iterators mailing list on SourceForge
Some bad news about python-iterat...@lists.sourceforge.net, looks like sourceforge lost a huge part of the mailing list: they have 0 message before Sep. 2001. So I think I'll soon drop the link(s) refering to it in the PEPs. -- [Julien Palard](https://mdk.fr) ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/ZF64Y53M3KEKAGROORJA6SD6GPX2HDJO/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-Dev] Re: name for new Enum decorator
I think a longer-named decorator, with a name that actually describes its behavior would be better than any smart short name in this case. "check_all_bits_defined" or something along it. On Fri, 28 May 2021 at 18:30, Ethan Furman wrote: > On 5/28/21 12:43 AM, Petr Viktorin wrote: > > On 28. 05. 21 5:24, Ethan Furman wrote: > > >> class FlagWithMasks(IntFlag): > >> DEFAULT = 0x0 > >> > >> FIRST_MASK = 0xF > >> FIRST_ROUND = 0x0 > >> FIRST_CEIL = 0x1 > >> FIRST_TRUNC = 0x2 > >> > >> SECOND_MASK = 0xF0 > >> SECOND_RECALC = 0x00 > >> SECOND_NO_RECALC = 0x10 > >> > >> THIRD_MASK = 0xF00 > >> THIRD_DISCARD = 0x000 > >> THIRD_KEEP = 0x100 > >> > >> Here we have three flags (FIRST_MASK, SECOND_MASK, THIRD_MASK) that > are aliasing values > >> that don't exist, but it seems intentional and not an error. > > > > Are you looking for a decorator for the whole Enum, or a way to mark > individual *values* as masks? > > The decorator is for whole enum. The issue is not that some values are > masks, but whether the absence of named bits > covered by the mask is an error. > > -- > ~Ethan~ > ___ > Python-Dev mailing list -- python-dev@python.org > To unsubscribe send an email to python-dev-le...@python.org > https://mail.python.org/mailman3/lists/python-dev.python.org/ > Message archived at > https://mail.python.org/archives/list/python-dev@python.org/message/OM5M774MP5QPLFXZ7OVGBPR7ZFB6X35A/ > Code of Conduct: http://python.org/psf/codeofconduct/ > ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/WX7YCSRRDJWLVJUMLGBZL34OP7JW4MDQ/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-Dev] Re: PEP 659: Specializing Adaptive Interpreter
> > The Instagram team behind the Cinder project may be interested to > review Mark's work before it's merged into Python development branch. > A design PEP would be more convenient than reviewing an concrete > implementation. I can't speak for others on the Cinder team, but I would definitely be happy to help review, and a design document would be great for that. I'm certainly curious what the design is for the Microsoft implementation and how it differs from our shadow code implementation. Right now I certainly don't have enough information to know what the differences are. And of course the reason to open source Cinder was to help avoid duplication of effort as obviously there's a lot of interest in making Python faster! So if there's interest in our shadow code implementation I'd be happy to work to break it out into more reviewable pieces as well - it's got some pretty natural ways to split it up. On Thu, May 27, 2021 at 2:21 PM Victor Stinner wrote: > Hi, > > The gilectomy was mentioned earlier in the thread. This project was > created by a core dev who had the permission to push directly his work > into the development branch, but it was done on a work. > > Another optimization project example was my experimental "FAT Python" > project. The main idea was to specialize functions with some > assumptions, and check these assumptions at the function entry. I > started in a fork and then wrote 3 PEPs to propose to merge the main > changes into Python development branch: > > * PEP 509 -- Add a private version to dict > * PEP 510 -- Specialize functions with guards > * PEP 511 -- API for code transformers > > The PEP 509 was accepted since it could be used for other > optimizations: Python now uses the dictionary version to optimize > LOAD_GLOBAL. > > The two other PEPs were rejected. Even if I was very disappointed when > they were rejected, it seems like it was a wize choice since I was > never able to make Python significantly faster (like 2x faster). It > was only 10-20% faster on some micro-benchmarks. I also had the > permission to push directly, and I think that it was nice to confront > my design and ideas to the community. > > I also understand that optimizing Python is really hard and it > requires a lot of preparation work. It's hard to sell the preparation > work since it only introduces regressions and noise without any > concrete speedup. All of this work is required to implement the real > interesting optimization. Moreover, few people are earger to review a > Python fork with deep and large changes in Python internals. The work > must be re-done step by step with more "atomic" (small) changes to > have a readable Git history. > > The Instagram team behind the Cinder project may be interested to > review Mark's work before it's merged into Python development branch. > A design PEP would be more convenient than reviewing an concrete > implementation. > > Victor > ___ > Python-Dev mailing list -- python-dev@python.org > To unsubscribe send an email to python-dev-le...@python.org > https://mail.python.org/mailman3/lists/python-dev.python.org/ > Message archived at > https://mail.python.org/archives/list/python-dev@python.org/message/CS7WDQYHJN7QV6TQW3CJZ2XRQRKX2RWT/ > Code of Conduct: http://python.org/psf/codeofconduct/ > ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/VGEBI3YC5I6ESO7SKZL44A3AGNO5OLFZ/ Code of Conduct: http://python.org/psf/codeofconduct/