[Python-Dev] Re: PEP 683: "Immortal Objects, Using a Fixed Refcount" (round 3)
On 10. 03. 22 3:35, Jim J. Jewett wrote: "periodically reset the refcount for immortal objects (only enable this if a stable ABI extension is imported?)" -- that sounds quite expensive, both at runtime and maintenance-wise. As I understand it, the plan is to represent an immortal object by setting two high-order bits to 1. The higher bit is the actual test, and the one representing half of that is a safety margin. When reducing the reference count, CPython already checks whether the refcount's new value is 0. It could instead check whether refcount & (not !immortal_bit) is 0, which would detect when the safety margin has been reduced to 0 -- and could then add it back in. Since the bit manipulation is not conditional, the only extra branch will occur when an object is about to be de-allocated, and that might be rare enough to be an acceptable cost. (It still doesn't prevent rollover from too many increfs, but ... that should indeed be rare in the wild.) The problem is that Py_DECREF is a macro, and its old behavior is compiled into some extensions. We can't change this without breaking the stable ABI. ___ 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/FPKK46N4RBAEJUU5PCQZ3SIZ7GREETTH/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-Dev] Re: RFC on PEP 655: Required[] and NotRequired[] for TypedDict
On 3/8/22 8:42 AM, Patrick Reader wrote: I think the names `Required` and `NotRequired` are too generic for something which can only be used in one context (`TypedDict`s), and > Could they be > put into a pseudo-module like `typing.io`, e.g. `TypedDict.Required`? It sounds like you are proposing something like: ``` from typing import TypedDict from typing.TypedDict import NotRequired # ๐ class Movie(TypedDict): title: str stars: NotRequired[int] ``` Is that really much different than: ``` from typing import NotRequired, TypedDict # ๐ class Movie(TypedDict): title: str stars: NotRequired[int] ``` Only the imports differ. And now users now have to specially remember that the "typing-related" NotRequired marker needs to imported not from `typing`, as is usual practice, but instead needs to be imported from somewhere else. it is not immediately obvious when reading code without context what the difference between `NotRequired` and `Optional` might be. Indeed PEP 655 ยง"How to Teach This" recommends not using both Optional and NotRequired in the same place, which might also mean the same file, and provides suggestions to avoid using Optional at all. Related: The word on the street is that "T|None" is likely to be a favored replacement for Optional in general going forward, since it's faster to type and doesn't require an extra import (of Optional from typing). Best, -- David Foster | Seattle, WA, USA Contributor to Python's type system ___ 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/ZEO56ZSUVWHOPGN4MASUNVHBOHBINBG3/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-Dev] Re: PEP 684: A Per-Interpreter GIL
On Wed, Mar 9, 2022 at 7:37 PM Carl Meyer wrote: > > Note that Instagram isn't exactly using Cinder. > > This sounds like a misunderstanding somewhere. Instagram server is > "exactly using Cinder" :) :) Thanks for clarifying, Carl. > > I'll have to check if Cinder uses the pre-fork model. > > It doesn't really make sense to ask whether "Cinder uses the pre-fork > model" -- Cinder is just a CPython variant, it can work with all the > same execution models CPython can. Instagram server uses Cinder with a > pre-fork execution model. Some other workloads use Cinder without > pre-forking. +1 -eric ___ 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/ZI6JXJJ2F6DCHTVYUVQFDNPCWEH76J6V/ Code of Conduct: http://python.org/psf/codeofconduct/