[Python-ideas] PEP 505: None-aware operators

Chris Angelico rosuav at gmail.com
Sun Jul 29 00:27:27 EDT 2018


On Sun, Jul 29, 2018 at 1:56 PM, Abe Dillon <abedillon at gmail.com> wrote:
>> Python does not have memory locations.
>
>
> CPython does, form the documentation on the `id` function:
>
>> CPython implementation detail: This is the address of the object in
>> memory.

Right, which is an important distinction; CPython, being a concrete
implementation, does involve memory. For instance, you can ask "how
many bytes of memory does this object take up?" and CPython can answer
that (sys.getsizeof). You can't ask that in Python generally, because
the abstract language doesn't have memory or any such concept.

The "None" object exists in the abstract sense. It will be present in
ANY Python implementation. In theory, a Python could use a null
pointer to represent None, just as long as you can't tell the
difference between that behaviour and any other.

> I'm not sure what performance implications there would be for adding a
> __none_check__ or whatever method to None.

Considering that None is a singleton, there's no need to create a
protocol for asking "are you None?". The obvious way to say "are you
None?" is to inquire if some object and None are the same object,
which is spelled "x is None".

ChrisA


More information about the Python-ideas mailing list