49 lines
1.4 KiB
Plaintext
49 lines
1.4 KiB
Plaintext
From: cgw at fnal.gov (Charles G Waldman)
|
|
Date: Tue, 27 Apr 1999 20:52:21 GMT
|
|
Subject: Long integers getting short shrift?
|
|
Message-ID: <14118.9093.292465.438475@buffalo.fnal.gov>
|
|
Content-Length: 1215
|
|
X-UID: 850
|
|
|
|
The functions Py_BuildValue and PyArg_ParseTuple don't seem to be
|
|
listed in the index of the Python/C API documentation. They are only
|
|
described in the Embedding and Extending docs.
|
|
|
|
The "L" format code for Long integers is not described anywhere,
|
|
AFAICT. I discovered it by reading source.
|
|
|
|
It seems that if you are on a system without the "long long" type then
|
|
the "L" format char is not available. The "L" format performs the
|
|
same function as the "PyLong_FromLongLong" function, but there's no
|
|
format character to get me the equivalent of "PyLong_FromLong". So,
|
|
if I am calling a Python function from C which is expecting a long int
|
|
as an arg, I am forced to write
|
|
|
|
result = PyObject_CallFunction(func, "O", PyLong_FromLong(x));
|
|
|
|
which isn't terrible but isn't as nice as writing
|
|
|
|
result = PyObject_CallFunction(func, "L", x);
|
|
|
|
which I can only do if the system has "long long" and x is of that
|
|
type... I'd like to be able to get regular C integers into Python
|
|
long's.
|
|
|
|
One reason for wanting this is that I often use long's in Python to
|
|
hold what would be in C an "unsigned int" - since there's no
|
|
"unsigned" type in Python, to represent a 32-bit value without
|
|
sign-bit I use a Python long.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|