How Python Implements "long integer"?

Pedram pm567426 at gmail.com
Sun Jul 5 18:34:37 CEST 2009


On Jul 5, 8:32 pm, Pedram <pm567... at gmail.com> wrote:
> On Jul 5, 8:12 pm, a... at pythoncraft.com (Aahz) wrote:
>
>
>
> > In article <6f6be2b9-49f4-4db0-9c21-52062d8ea... at l31g2000yqb.googlegroups.com>,
>
> > Pedram  <pm567... at gmail.com> wrote:
>
> > >This time I have a simple C question!
> > >As you know, _PyLong_New returns the result of PyObject_NEW_VAR. I
> > >found PyObject_NEW_VAR in objimpl.h header file. But I can't
> > >understand the last line :( Here's the code:
>
> > >#define PyObject_NEW_VAR(type, typeobj, n) \
> > >( (type *) PyObject_InitVar( \
> > >      (PyVarObject *) PyObject_MALLOC(_PyObject_VAR_SIZE((typeobj),
> > >(n)) ),\
> > >      (typeobj), (n)) )
>
> > >I know this will replace the PyObject_New_VAR(type, typeobj, n)
> > >everywhere in the code and but I can't understand the last line, which
> > >is just 'typeobj' and 'n'! What do they do? Are they make any sense in
> > >allocation process?
>
> > Look in the code to find out what PyObject_InitVar() does -- and, more
> > importantly, what its signature is.  The clue you're missing is the
> > trailing backslash on the third line, but that should not be required if
> > you're using an editor that shows you matching parentheses.
> > --
> > Aahz (a... at pythoncraft.com)           <*>        http://www.pythoncraft.com/
>
> > "as long as we like the same operating system, things are cool." --piranha
>
> No, they wrapped the 3rd line!
>
> I'll show you the code in picture below:http://lh3.ggpht.com/_35nHfALLgC4/SlDVMEl6oOI/AAAAAAAAAKg/vPWA1gttvHM...
>
> As you can see the PyObject_MALLOC has nothing to do with typeobj and
> n in line 4.

Oooooh! What a mistake! I got it! they're Py_Object_InitVar
parameters.
Sorry and Thanks!



More information about the Python-list mailing list