[issue41618] [C API] How many slots of static types should be exposed in PyType_GetSlot()

2021-01-15 Thread hai shi


hai shi  added the comment:

>Not a function, shouldn't be used with PyType_Slot:
>  * tp_dict - I'd add a PyType_GetDict if there is a need to get this
>  * tp_mro - I'd add a PyType_GetMRO if there is a need to get this

I checked some other projects which use type fileds directly.
cpython doesn't expose the tp_dict and tp_mro directly in headers. 
I am not sure which way is more better(calling function vs using fileld 
directly).

refs:
https://gitlab.gnome.org/GNOME/pygobject/-/blob/master/gi/gimodule.c#L1168
https://github.com/biolab/orange2/blob/db40a9449cb45b507d63dcd5739b223f9cffb8e6/source/orange/cls_orange.cpp#L587

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41618] [C API] How many slots of static types should be exposed in PyType_GetSlot()

2020-12-29 Thread Petr Viktorin


Petr Viktorin  added the comment:

Documentation for developers *of* CPython should generally go in the dev guide, 
a comment in the code, or in issues like this.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41618] [C API] How many slots of static types should be exposed in PyType_GetSlot()

2020-11-07 Thread hai shi


hai shi  added the comment:

> Do you mean something like "only expose a slot if you have a reason for > 
> exposing it"? That sounds like a tautology.
> Where in the docs would this go?

Add a friend Note in docs of `PyType_GetSlot` MAYBE?

> You mean nb_reserved, right?
Yes, thanks for your description.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41618] [C API] How many slots of static types should be exposed in PyType_GetSlot()

2020-11-05 Thread Petr Viktorin


Petr Viktorin  added the comment:

My views on individual slots:

Not a function, shouldn't be used with PyType_Slot:
  * tp_dict - I'd add a PyType_GetDict if there is a need to get this
  * tp_mro - I'd add a PyType_GetMRO if there is a need to get this
(There are existing slots that aren't functions; I'd like to deprecate them in 
the long term.)

internal use only, do not expose:
  * tp_cache
  * tp_subclasses
  * tp_weaklist
  * tp_as_*

Not part of limited API, do not expose:
  * tp_vectorcall

Can be exposed if we deem all of the related API stable:
  * bf_getbuffer
  * bf_releasebuffer

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41618] [C API] How many slots of static types should be exposed in PyType_GetSlot()

2020-11-03 Thread Petr Viktorin


Petr Viktorin  added the comment:

> Can we write those info to docs? In case some developer want to exposing slot 
> in future.

Do you mean something like "only expose a slot if you have a reason for 
exposing it"? That sounds like a tautology.
Where in the docs would this go?

> nb_inserved in PyNumberMethods should be removed?

You mean nb_reserved, right?
It can't be removed; old-style initialization is positional.
But it could be replaced according to PEP387:
- in 3.x, raise a warning if it is not set to NULL (in static types)
- in 3.x+2, throw an error if it is not set to NULL (in static types)
- in 3.x+3 or later, it can be replaced by another slot, if there's something 
we need to add to PyNumberMethods

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41618] [C API] How many slots of static types should be exposed in PyType_GetSlot()

2020-10-30 Thread hai shi


hai shi  added the comment:

> IMO, a slot should be exposed if there is some reason for exposing it.

Can we write those info to docs? In case some developer want to exposing slot 
in future.

> Which other slots are we missing?

nb_inserved in PyNumberMethods should be removed?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41618] [C API] How many slots of static types should be exposed in PyType_GetSlot()

2020-10-20 Thread Petr Viktorin


Petr Viktorin  added the comment:

Also: PyType_GetSlot should return a function pointer, not data.

For some slots (Py_tp_doc, Py_tp_methods, Py_tp_members, Py_tp_getset) that 
ship has sailed, but for new ones, we should honor the distinction between data 
and function pointers. The C standard says they're distinct, so it might bite 
us in the future (e.g. compiling to WebAssembly).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41618] [C API] How many slots of static types should be exposed in PyType_GetSlot()

2020-09-08 Thread Petr Viktorin


Petr Viktorin  added the comment:

IMO, a slot should be exposed if there is some reason for exposing it.

bpo-41073 talks about tp_dealloc, which is already exposed as Py_tp_dealloc.
Recently, Py_bf_* slots were exposed (but not as part of the limited API), in 
bpo-40724 which links to the reasons for exposing them.

Which other slots are we missing?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41618] [C API] How many slots of static types should be exposed in PyType_GetSlot()

2020-08-23 Thread hai shi


hai shi  added the comment:

related bpo: bpo-41073

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41618] [C API] How many slots of static types should be exposed in PyType_GetSlot()

2020-08-23 Thread hai shi


New submission from hai shi :

In order to resolve bpo41073, we want to extend `PyType_GetSlot()` to accept 
static types. But there have another question we should be considered: How many 
slots should be exposed in `PyType_GetSlot()`.

petr's opinion from PR-21931:I would not want to expose the Py_tp_as_* slots at 
all; their contents are covered in other slots that should be used instead. And 
slots like Py_tp_version_tag are specific to CPython; I don't think they should 
be exposed in the general C API.

--
components: C API
messages: 375808
nosy: petr.viktorin, shihai1991, vstinner
priority: normal
severity: normal
status: open
title: [C API] How many slots of static types should be exposed in 
PyType_GetSlot()
type: enhancement
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com