[Python-Dev] PEP 567 v2

2017-12-27 Thread Yury Selivanov
This is a second version of PEP 567. A few things have changed: 1. I now have a reference implementation: https://github.com/python/cpython/pull/5027 2. The C API was updated to match the implementation. 3. The get_context() function was renamed to copy_context() to better reflect what it is

Re: [Python-Dev] Documenting types outside of typing

2017-12-27 Thread Ivan Levkivskyi
FWIW the same problem was discussed a year ago when documenting typing. At that time the discussion was not conclusive, so that some types use class:: directive while other use data:: directive. At that time Guido was in favour of data:: and now in view of PEP 560 many types in typing will stop

Re: [Python-Dev] Supporting functools.singledispatch with classes.

2017-12-27 Thread Ethan Smith
Okay, if there is no further feedback, I will work on a singledispatchmethod decorator like partialmethod. For the future perhaps, would it not be possible to tell that the passed argument is a descriptor/function and dispatch to the correct implementation, thus not needing two functions for

Re: [Python-Dev] When val=b'', but val == b'' returns False - bytes initialization

2017-12-27 Thread Antoine Pitrou
On Wed, 27 Dec 2017 17:28:41 +0100 Antoine Pitrou wrote: > On Wed, 27 Dec 2017 14:19:16 + > Jonathan Underwood wrote: > > Hello, > > > > I am not sure if this is expected behaviour, or a bug. > > > > In a C extension module, if I create

[Python-Dev] Documenting types outside of typing

2017-12-27 Thread Barry Warsaw
In his review of PR#4911, Antoine points to the documentation of two type definitions in importlib.resources, Package and Resource. https://github.com/python/cpython/pull/4911/files#diff-2a479c407f7177f3d7cb876f244e47bcR804 One question is what markup to use for type definitions. I’m using

Re: [Python-Dev] When val=b'', but val == b'' returns False - bytes initialization

2017-12-27 Thread Antoine Pitrou
On Wed, 27 Dec 2017 14:19:16 + Jonathan Underwood wrote: > Hello, > > I am not sure if this is expected behaviour, or a bug. > > In a C extension module, if I create and return an empty bytes object like > this: > > val = PyBytes_FromStringAndSize (NULL,

[Python-Dev] When val=b'', but val == b'' returns False - bytes initialization

2017-12-27 Thread Jonathan Underwood
Hello, I am not sure if this is expected behaviour, or a bug. In a C extension module, if I create and return an empty bytes object like this: val = PyBytes_FromStringAndSize (NULL, 20); Py_SIZE(val) = 0; Then from the Python interpreter's perspective: isinstance(val, bytes)