On May 15, 11:54 am, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Mon, 14 May 2007 21:45:26 -0700, seyensubs wrote:
> > Ah, I see, just slicing it like that.. nice! But after doing some timing
> > tests, the version that's in place and using partitions is about twice
> > faster than the non hybr
On Mon, 14 May 2007 21:45:26 -0700, seyensubs wrote:
> Ah, I see, just slicing it like that.. nice! But after doing some timing
> tests, the version that's in place and using partitions is about twice
> faster than the non hybrid qSort. The hybrid one, with insertionsSort
> used for smaller lists
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
| Teach said that the optimal threshold in hybrids is 14-16, but guess
| he wasn't so right after all =\\ The overhead of using insertion sort
| on a longer list turns out to be faster than just piling on
| recursions, when confronted wi
On May 15, 5:35 am, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Mon, 14 May 2007 09:49:56 -0700, Thomas Nelson wrote:
> > The thing is that [x for x in List[1:]...] is a brand new list created
> > by iterating over the old one.
> > How about:
> > qSortHelp(List):
> > newlist = qSort(List)
>
On Mon, 14 May 2007 09:49:56 -0700, Thomas Nelson wrote:
> The thing is that [x for x in List[1:]...] is a brand new list created
> by iterating over the old one.
> How about:
> qSortHelp(List):
> newlist = qSort(List)
> for i, val in enumerate(newlist):
> List[i] = val
> You have
[EMAIL PROTECTED] wrote:
> I see. I figured that list comprehensions made another list(duh), but
> I thought I could relink the object(List) to the new list and keep it
> once the function ended.
>
> Is it possible to pass a reference(to an object.. Like 'List',
> basically) to a function and chan
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
|I have the following implementations of quicksort and insertion sort:
|
| def qSort(List):
|if List == []: return []
|return qSort([x for x in List[1:] if x< List[0]]) + List[0:1] + \
| qSort([x for x in List[1:] if x>
I see. I figured that list comprehensions made another list(duh), but
I thought I could relink the object(List) to the new list and keep it
once the function ended.
Is it possible to pass a reference(to an object.. Like 'List',
basically) to a function and change the reference to point to
somethin
On May 14, 12:05 pm, [EMAIL PROTECTED] wrote:
> I have the following implementations of quicksort and insertion sort:
>
> def qSort(List):
> if List == []: return []
> return qSort([x for x in List[1:] if x< List[0]]) + List[0:1] + \
>qSort([x for x in List[1:] if x>=List[0]])
>
On May 14, 11:05 am, [EMAIL PROTECTED] wrote:
> I have the following implementations of quicksort and insertion sort:
>
> def qSort(List):
> if List == []: return []
> return qSort([x for x in List[1:] if x< List[0]]) + List[0:1] + \
>qSort([x for x in List[1:] if x>=List[0]])
>
I have the following implementations of quicksort and insertion sort:
def qSort(List):
if List == []: return []
return qSort([x for x in List[1:] if x< List[0]]) + List[0:1] + \
qSort([x for x in List[1:] if x>=List[0]])
def insertSort(List):
for i in range(1,len(List)):
11 matches
Mail list logo