[Python-Dev] Error in PEP3118?
Travis Oliphant
oliphant.travis at ieee.org
Mon Feb 11 20:34:27 CET 2008
Thomas Heller wrote:
> Travis Oliphant schrieb:
>
>>
>> The intent of the struct syntax is to handle describing memory. The
>> point is not to replicate how the C-compiler deals with statically
>> defined N-D arrays. Thus, even though the struct syntax allows
>> *communicating* the intent of a contiguous block of memory inside a
>> structure as an N-d array, the fundamental memory block is the
>> equivalent of a 1-d array in C.
>>
>> So, I think the example is correct (and intentional).
>
> Sorry, I do not think so. If you use a 2-d array in the example, you
> must describe it correctly. The difference between this pep and the old
> buffer interface is that the pep allows to describe both how the compiler
> sees the memory block plus the size and layout of the memory block, while
> the old buffer interface only describes single-segment memory blocks.
> And 'double data[16][4]' *is* a single memory block containing a 2-d array,
> and *not* an array of pointers.
>
I don't understand what you mean by "must describe it correctly". The
size and layout of the memory block description of the PEP is not
supposed to be dependent on the C-compiler. It should also be able to
define memory as used in Fortran, C#, a file, or whatever. So, I don't
understand the insistence that the example use C-specific 2-d array syntax.
The example as indicated is correct. It is true that the 2-d nature of
the block of data is only known by Python in this example. You could
argue that it would be more informative by showing the C-equivalent
structure as a 2-d array. However, it would also create the possibility
of confusion by implying an absolute relationship between the C-compiler
and the type description.
Your insistence that the example is incorrect makes me wonder what point
is not being communicated between us. Clearly there is overlap between
C structure syntax and the PEP syntax, but the PEP type syntax allows
for describing data in ways that the C compiler doesn't.
I'd rather steer people away from statically defined arrays in C and
don't want to continually explain how they are subtly different.
My perception is that you are seeing too much of a connection between
the C-compiler and the PEP description of memory. Perhaps that's not
it, and I'm missing something else.
Best regards,
-Travis O.
More information about the Python-Dev
mailing list