Long integers getting short shrift?

Charles G Waldman cgw at fnal.gov
Tue Apr 27 19:13:20 EDT 1999


Ivan Van Laningham writes:

 > ????  I have Python running on my UnixWare system at home, and the long
 > types are easily accessible. 

Perhaps I was unclear, I'm not saying that the long type is not
available; I'm referring to the level of support for Long objects in
the Python/C API, in particular the functions PyArg_ParseTuple and
PyObject_CallFunction.  Below is the snippet of code in getargs.c that
handles the "L" format character...  I was wishing for something
similar to "L" that would take a plain C int and make a Python Long
out of it... I don't know what letter I'd use since l and L are
already taken!

It's not too important,  one can always use the "O" format letter and
handle the arg. specially with PyLong_FromLong;  it's just a bit ugly
to have to do so.

	
#ifdef HAVE_LONG_LONG
	case 'L': /* LONG_LONG */
		{
			LONG_LONG *p = va_arg( *p_va, LONG_LONG * );
			LONG_LONG ival = PyLong_AsLongLong( arg );
			if( ival == (LONG_LONG)-1 && PyErr_Occurred() ) {
				return "long<L>";
			} else {
				*p = ival;
			}
			break;
		}
#endif





More information about the Python-list mailing list