Re: PROPOSAL: A Generic Python Object Interface for Python C Modules

Aaron Watters (aaron@funcity.njit.edu)
Mon, 6 Mar 1995 15:07:40 GMT

In article <JFULTON.95Mar2141529@disqvarsa.er.usgs.GOV> jfulton@disqvarsa.er.usgs.GOV (Jim Fulton ) writes:
>>> > PyObject* PyObject_CallMethod(object, method-name, args...)

[danger, danger Dr. Robinson! please don't get pissed, anyone.]

Allow me to go out in left field for an unlimited period of time.

I think (PyObject *) should be replaced everywhere with PyObjRef
and all direct accesses to the object structure should be replaced with C
macros.

The reason is that I have always been uncomfortable with allocating
things like ints and floats on the heap, and with an appropriate
PyObjRef abstraction it would be possible to move away from this.
Ie, instead of a pointer we could define PyObjRef to be a pair
(type, ref)
where type is a ptr to the type structure for the object and ref is
an int, if the object is an int
a float, if the object is a float
another small object, if the object is another small object
a pointer to the object representation otherwise.

This would allow small objects to be allocated on the stack as
literal PyObjRef's with no dynamic memory involved... cache
memory locality speedups... fewer function calls... fewer mallocs...
blah blah blah... Downside: maybe less memory sharing for ints and
floats, but is this really a big deal?

Sadly, this would involve a major overhaul of every piece of C
code that touches Python. Oh well. Just a thought.
-a.
=======
A mantra for the '90's:
"I have no reason to whine: so grow up."
-- repeat indefinitely, ever louder and faster, until you reach a
higher plane of consciousness.