Re: How Python Implements "long integer"?

2009-07-07 Thread Pedram
On Jul 7, 1:10 pm, Mark Dickinson wrote: > On Jul 6, 4:13 pm, Pedram wrote: > > > > > On Jul 6, 5:46 pm, Mark Dickinson wrote: > > > On Jul 6, 1:24 pm, Pedram wrote: > > > > > OK, fine, I read longobject.c at last! :) > > > > I found that

Re: How Python Implements "long integer"?

2009-07-06 Thread Pedram
Hello Mr. Dickinson. Glad to see you again :) On Jul 6, 5:46 pm, Mark Dickinson wrote: > On Jul 6, 1:24 pm, Pedram wrote: > > > OK, fine, I read longobject.c at last! :) > > I found that longobject is a structure like this: > > > struct _longobject { >

Re: How Python Implements "long integer"?

2009-07-06 Thread Pedram
OK, fine, I read longobject.c at last! :) I found that longobject is a structure like this: struct _longobject { struct _object *_ob_next; struct _object *_ob_prev; Py_ssize_t ob_refcnt; struct _typeobject *ob_type; digit ob_digit[1]; } And a digit is a 15-item array of C's un

Re: How Python Implements "long integer"?

2009-07-05 Thread Pedram
On Jul 5, 8:32 pm, Pedram wrote: > On Jul 5, 8:12 pm, a...@pythoncraft.com (Aahz) wrote: > > > > > In article > > <6f6be2b9-49f4-4db0-9c21-52062d8ea...@l31g2000yqb.googlegroups.com>, > > > Pedram   wrote: > > > >This time I have a simple C

Re: How Python Implements "long integer"?

2009-07-05 Thread Pedram
On Jul 5, 8:12 pm, a...@pythoncraft.com (Aahz) wrote: > In article > <6f6be2b9-49f4-4db0-9c21-52062d8ea...@l31g2000yqb.googlegroups.com>, > > > > Pedram   wrote: > > >This time I have a simple C question! > >As you know, _PyLong_New returns the

Re: How Python Implements "long integer"?

2009-07-05 Thread Pedram
Hello again, 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(

Re: How Python Implements "long integer"?

2009-07-05 Thread Pedram
7;s a bit more > complicated because small integers are cached.) Oh, I didn't see long_as_number before. I'm reading it. That was very helpful, thanks. > If you have more specific questions I'll have a go at answering them. > > Mark Thank you a million. I will write yo

Re: How Python Implements "long integer"?

2009-07-05 Thread Pedram
On Jul 5, 1:57 pm, Mark Dickinson wrote: > On Jul 5, 8:38 am, Pedram wrote: > > > Hello, > > I'm reading about implementation of long ints in Python. I downloaded > > the source code of CPython and will read the longobject.c, but from > > where I should st

How Python Implements "long integer"?

2009-07-05 Thread Pedram
Hello, I'm reading about implementation of long ints in Python. I downloaded the source code of CPython and will read the longobject.c, but from where I should start reading this file? I mean which function is the first? Anyone can help? Thanks Pedram -- http://mail.python.org/mailman/lis

Re: A question about fill_free_list(void) function

2009-07-02 Thread Pedram
On Jul 2, 1:11 pm, Peter Otten <__pete...@web.de> wrote: > Pedram wrote: > > On Jul 1, 10:01 pm, Christian Heimes wrote: > >> Pedram schrieb: > > >> > Hello community, > >> > I'm reading the CPython interpreter source code, > >> >

Re: A question about fill_free_list(void) function

2009-07-01 Thread Pedram
On Jul 1, 10:01 pm, Christian Heimes wrote: > Pedram schrieb: > > > Hello community, > > I'm reading the CPython interpreter source code, > > first, if you have something that I should know for better reading > > this source code, I would much appreciate that :)

Re: A question about fill_free_list(void) function

2009-07-01 Thread Pedram
Oh... I got it! :) I found this line in ctypes.h: #define Py_TYPE(q) = ((PyObject *)(q))->ob_next; So those lines are trying to set the blocks type from rear to front. But I still don't know why after the while (when q is equal to p), the Py_TYPE(q) set to NULL! -- http://mail.python.org/mailman/

A question about fill_free_list(void) function

2009-07-01 Thread Pedram
Hello community, I'm reading the CPython interpreter source code, first, if you have something that I should know for better reading this source code, I would much appreciate that :) second, in intobject.c file, I read the following code in fill_free_list function that I couldn't understand: while