Steven D'Aprano wrote:
In an attempt to keep this post from hitting the ridiculous length of one
(Aside: I've learned one thing in this discussion. Despite the number of
sources I've read that claim that if you pass an array to a C function
the entire array will be copied, this does not appear to be true....)
Since C does not have an array type, it is impossible to pass an array.
int *a, b[10] declares *both* a and b as int pointers. As I remember,
the only difference is that b is initialized to the address of an
allocated block of 10. In expressions, b is an int pointer, just like
a, and a[i] and b[i] are defined the same, as *(a+i) and *(b+i), where
the addition is pointer arithmetic. Function definitions can only define
parameters as pointers (and lots else), not arrays. So passing either a
or b passes the address it represents. (Function names also represent
addresses in expressions, whereas, I believe, in C99 at least, struct
names represent the struc, not its address.)
tjr
--
http://mail.python.org/mailman/listinfo/python-list