[Python C API] Two Different Questions :: PySlice_GetIndices(), copying an object.

Michael Hudson mwh at python.net
Mon Dec 9 05:55:26 EST 2002


iggeres at yahoo.es (Iggeres Bet) writes:

> > > -2- Doing a shallow copy using the C API.
[...]
> > > The object's class is defined on Python, not in C.
> > 
> > How would you do a shallow copy of it in Python?
> 
> So, I need to import copy and call copy to do it.
> Nobody needed a faster shallow copy using the C API?

Well, the thing is, I think what you're asking for is more or less
impossible.

You can do shallow copies of, say, lists and dicts through the C API,
but a shallow copy of an arbitrary object, no.  You could rewrite
copy.py in C if you wanted, I guess, but I personally don't see the
point.  But then I never use the copy module either, so perhaps that
isn't surprising.

Cheers,
M.

-- 
  Enlightenment is probably antithetical to impatience.
                                        -- Erik Naggum, comp.lang.lisp



More information about the Python-list mailing list