Roundup Robot added the comment:
New changeset 655d7a55c165 by Martin v. Löwis in branch 'default':
Issue #17162: Add PyType_GetSlot.
http://hg.python.org/cpython/rev/655d7a55c165
--
nosy: +python-dev
___
Python tracker rep...@bugs.python.org
Martin v. Löwis added the comment:
Thanks for the reviews; this is now committed.
--
resolution: - fixed
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17162
___
Roundup Robot added the comment:
New changeset eaae4008327d by Victor Stinner in branch 'default':
Issue #17162: Fix compilation, replace non-breaking space with an ASCII space
http://hg.python.org/cpython/rev/eaae4008327d
--
___
Python tracker
Martin v. Löwis added the comment:
It's certainly possible to write a proper dealloc - just call PyObject_Del
directly. This is correct if the type isn't subclassable, and works if it
actually isn't subclassed, or if the subclass object can also be released
through PyObject_Del.
That this
Larry Hastings added the comment:
I was thinking of a subclass of an existing class, both implemented in C.
collections.Counter does that, but it uses _PyType_LookupId() which is in the
limited API.
Would it be possible to achieve equivalent functionality by using
_PyType_LookupId()? If
Larry Hastings added the comment:
(And, I freely admit I don't understand all this that well and that could be a
very dumb question.)
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17162
Martin v. Löwis added the comment:
I'm not sure we are looking at the same code base, I look at
http://hg.python.org/cpython/file/b56ce3410ca6/Lib/collections/__init__.py#l401
and ISTM that collections.Counter is *not* implemented in C. Also, according to
Martin v. Löwis added the comment:
If the set of slots gets extended, extensions would have to opt-in to use the
newer slots, i.e. the availability of slot numbers should be conditional at
compile-time.
Returning 0 for slots not supported in a version seems fine to me as well
(after
Larry Hastings added the comment:
I thought I replied to this... weird.
Do I understand correctly that it's basically impossible to write a proper
custom deallocator in the limited API right now, because you can't get access
to your base class's tp_free?
(If so, why didn't anybody notice?)
Larry Hastings added the comment:
Also, isn't it reasonable to pass in non-heap type objects? I realize
supporting this would complicate the implementation a great deal.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17162
Martin v. Löwis added the comment:
I propose a more general solution: add a function PyType_GetSlot.
--
keywords: +patch
Added file: http://bugs.python.org/file33762/getslot.diff
___
Python tracker rep...@bugs.python.org
STINNER Victor added the comment:
+return *(void**)(((char*)type) + slotoffsets[slot]);
New Python versions may add new slots. What do you think of returning NULL if
the slot number is higher than the maximum slot?
It looks like #define Py_tp_free 74 is the highest slot number since
Changes by Larry Hastings la...@hastings.org:
--
nosy: +larry
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17162
___
___
Python-bugs-list mailing
New submission from Bradley Froehle:
I tried to implement a custom extension type using PyType_FromSpec and
Py_LIMITED_API but couldn't implement tp_dealloc:
static void mytype_dealloc(mytypeobject *self)
{
// free some fields in mytypeobject
Py_TYPE(self)-tp_free((PyObject *) self);
Bradley Froehle added the comment:
I should mention that essentially what I'm advocating is renaming and exposing
`object_dealloc` in Objects/typeobject.c.
The proper name is not obvious to me... should it be PyObject_GenericDealloc
since it acts on objects? Or PyType_GenericDealloc since it
Changes by Antoine Pitrou pit...@free.fr:
--
nosy: +loewis
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17162
___
___
Python-bugs-list mailing
16 matches
Mail list logo