Re: Timsort in Cpython

2013-06-19 Thread sean . westfall
On Sunday, June 16, 2013 1:16:02 PM UTC-7, Dennis Lee Bieber wrote:
> On Sun, 16 Jun 2013 09:15:11 -0700 (PDT), [email protected] declaimed
> 
> the following:
> 
> 
> 
> >sorry about that. I'm new to google groups. I'm trying to make sense of 
> >python's implementation of timsort through cpython: 
> >http://hg.python.org/cpython/file/default/Objects/listobject.c
> 
> >
> 
>   Since you are new to GoogleGroups, if you can, run away from it as fast
> 
> as possible. While material may look okay on their system, it is
> 
> practically trashed when getting out into the real world. (Paragraphs
> 
> either come in as long lines with no wrapping [Usenet/Email convention is
> 
> for 80 character lines, and to allow for > quotes original text should wrap
> 
> around 72-75], or they end up double-spacing stuff that comes in following
> 
> the 80 character line length (GG is treating hard end-of-line as a
> 
> paragraph marker, and on quoting, adding a blank line between these
> 
> "paragraphs")
> 
> 
> 
>   Either subscribe to the mailing list (and use a real mail client rather
> 
> than web-mail) or use a news reader; if your ISP doesn't provide an NNTP
> 
> server carrying comp.lang.python, it is available from Gmane as
> 
> gmane.comp.python.general (the mailing list and comp.lang.python are cross
> 
> linked, and Gmane shows the mailing list as if it were a Usenet news group)
> 
> 
> 
>   And just another comment: preference on the group is "trim quoted
> 
> material and comment below the quote (or interspersed with the quotes)"...
> 
> The style created with M$ Outlook (Outlook goes out of its way to make it
> 
> impossible to trim/intersperse -- it considers quoted material as a
> 
> photocopy attached to the back of a new letter) in which one comments at
> 
> the top of the quoted material, and never trims to relevant material is
> 
> frowned upon.
> 

Understood. I just subscribed to the news group, though I'm using gmail. 
hopefully it will work better than google groups.

I'll keep all the advice here in mind whenever I post.

> -- 
> 
>   Wulfraed Dennis Lee Bieber AF6VN
> 
> [email protected]://wlfraed.home.netcom.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Timsort in Cpython

2013-06-19 Thread sean . westfall
On Sunday, June 16, 2013 1:33:17 PM UTC-7, Ian wrote:
> On Sat, Jun 15, 2013 at 10:05 PM,   wrote:
> 
> > Yes I've read it. Very interesting read. There are other resources too 
> > online that make it very clear, for instance the wikipedia articles is 
> > pretty good.
> 
> >
> 
> > Though, if anyone would be interested in helping me out further -- though 
> > by all means, I'm not lazy, I can figure it myself. But, I wanted to pass 
> > in variables into listsort and watch timsort work line by line in gdb.
> 
> >
> 
> > listsort(PyListObject *self, PyObject *args, PyObject *kwds)
> 
> >
> 
> > I've never worked with Cpython source before, but it looks like PyObject is 
> > just some type of general strut.. I think anyway. How does python represent 
> > a list of ints in source? and what are the two second arguments for, 
> > assuming the first is the list strut.
> 
> 
> 
> A PyObject* generally references any Python object.  The subtype
> 
> PyListObject* more specifically references a Python list.  The above
> 
> signature corresponds to this Python function signature:
> 
> 
> 
> def listsort(self, *args, **kwds):
> 
> 
> 
> The first argument self is the list object to be operated on.  The
> 
> second argument args is a Python tuple containing any other positional
> 
> arguments that were passed into the method.  The third argument kwds
> 
> is a Python dict containing any keyword arguments that were passed
> 
> into the method.

The second argument takes the tuple which determines which varialble(key) to 
use the comparator on. And the third determines whether to return the list in 
ascending or descending order. But how do these PyObject* look in C?

How does a PyListObject* look declared in CPython. How would something like 
this list = [2, 1, 5, 6, 10] look in CPython. Or what about something more 
complicated -- mlist = [('A',1),('B',2),('C',3)].

Thanks for the help.
-- 
http://mail.python.org/mailman/listinfo/python-list