This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 00/14] add a smart pointer for PyObject*
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Fri, 11 Nov 2016 01:18:39 +0000
- Subject: Re: [RFA 00/14] add a smart pointer for PyObject*
- Authentication-results: sourceware.org; auth=none
- References: <1478497656-11832-1-git-send-email-tom@tromey.com>
Hi Tom,
Great to see this finally happen. Congrats. :-)
I read the whole series now, and it all looks great to me. Once
patch #1 is fixed, it's fine with me to put it all in.
I did wonder about shortening the name to "gdbpy_ref". That's how I end
up reading "gdbpy_reference" in my mind after seeing it so many
times. :-) You already picked a shorter name as header file
name -- py-ref.h -- and that's typed way less often. :-)
Anyway, certainly not very important. Just mentioning in case
you had already considered but didn't know what others would think.
I wonder whether it'd be desirable to add more methods to
gdbpy_reference, so you'd have code like:
gdbpy_reference sort_func = module.GetAttrString ("execute_frame_filters");
instead of:
gdbpy_reference sort_func (PyObject_GetAttrString (module.get (),
"execute_frame_filters"));
etc.
And maybe add some C++ classes that inherit from gdbpy_reference for
specific Python types (e.g python tuple or list), which would provide
methods that would only make sense for those types.
Did you consider things like these? Or maybe you did but thought
they'd obfuscate?
Also, somewhat related, I briefly looked at making our custom Python
types C++ classes before, so they could themselves hold other
C++ classes, std::string, etc., though I didn't find how to
coerce Python to use operator new with PyTypeObject types.
There must be some way though.
Thanks,
Pedro Alves