Variable size/Set: Difference between revisions

Content added Content deleted
(Things like hash tables are now stored in a more optimised manner.)
(Add Python ctypes)
Line 43: Line 43:


In Perl, memory is readily and happily traded for expressiveness and ease of use.
In Perl, memory is readily and happily traded for expressiveness and ease of use.

=={{header|Python}}==
For compatibility with the calling conventions of external C functions, the [http://docs.python.org/library/ctypes.html?highlight=ctypes#module-ctypes ctypes module] has functions that map data types and sizes between Python and C:
<table class="docutils" border="1">
<tr>
<th class="head">ctypes type</th>
<th class="head">C type</th>
<th class="head">Python type</th>
</tr>
<tr>
<td>c_char</td>
<td>char</td>
<td>1-character string</td>
</tr>
<tr>
<td>c_wchar</td>
<td>wchar_t</td>
<td>1-character unicode string</td>
</tr>
<tr>
<td>c_byte</td>
<td>char</td>
<td>int/long</td>
</tr>
<tr>
<td>c_ubyte</td>
<td>unsigned char</td>
<td>int/long</td>
</tr>
<tr>
<td>c_short</td>
<td>short</td>
<td>int/long</td>
</tr>
<tr>
<td>c_ushort</td>
<td>unsigned short</td>
<td>int/long</td>
</tr>
<tr>
<td>c_int</td>
<td>int</td>
<td>int/long</td>
</tr>
<tr>
<td>c_uint</td>
<td>unsigned int</td>
<td>int/long</td>
</tr>
<tr>
<td>c_long</td>
<td>long</td>
<td>int/long</td>
</tr>
<tr>
<td>c_ulong</td>
<td>unsigned long</td>
<td>int/long</td>
</tr>
<tr>
<td>c_longlong</td>
<td>__int64 or long long</td>
<td>int/long</td>
</tr>
<tr>
<td>c_ulonglong</td>
<td>unsigned __int64 or
unsigned long long</td>
<td>int/long</td>
</tr>
<tr>
<td>c_float</td>
<td>float</td>
<td>float</td>
</tr>
<tr>
<td>c_double</td>
<td>double</td>
<td>float</td>
</tr>
<tr>
<td>c_longdouble</td>
<td>long double</td>
<td>float</td>
</tr>
<tr>
<td>c_char_p</td>
<td>char * (NUL terminated)</td>
<td>string or None</td>
</tr>
<tr>
<td>c_wchar_p</td>
<td>wchar_t * (NUL terminated)</td>
<td>unicode or None</td>
</tr>
<tr>
<td>c_void_p</td>
<td>void *</td>
<td>int/long or None</td>
</tr>
</table>


=={{header|Tcl}}==
=={{header|Tcl}}==