develooper Front page | perl.perl5.porters | Postings from January 2004

Re: in-place sort ( was Re: [perl #25263] sort -u )

Thread Next
From:
Tels
Date:
January 28, 2004 09:27
Subject:
Re: in-place sort ( was Re: [perl #25263] sort -u )
Message ID:
200401281824.58355@bloodgate.com
-----BEGIN PGP SIGNED MESSAGE-----

Moin,

On Wednesday 28 January 2004 16:00, John P. Linderman wrote:
> Quoth Jim Cromie:
> > is there a sensible, not overly subtle, way to do any of this ?
>
> Without wishing to sound flippant, if one is at the edge of
> "Out of memory" problems, it won't be long before any savings
> by doing an in-place sort also cease to matter.  It's probably
> time to think about a different algorithm, like piping the sort
> through an external routine, which isn't constrained to do
> everything in main memory.
>

Disk access is _very_ slow, and running out of memory will just swap, which 
would probably achive the same result (disk access, works, but very slow).

In any event, _doubling_ the memory requirements just because the sort 
cannot be done in place is quite heavy in some situations.

> For what it's worth, the _qsort sort pragma will do an in-place
> sort (unless you want it stabilized, in which case the extra
> copy comes right back again, as the "ascii art near line 1293"
> describes.)  But we're talking an array (or two) of *pointers*
> to the array of who-knows-what that's actually being sorted,
> so whether there's one pointer array or two (or three) isn't
> likely to figure prominently in the impending doom if you're
> at the edge of memory.  -- jpl

I have to read that paragraph after I head some sleep :)

Best wishes,

Tels

- -- 
 Signed on Wed Jan 28 18:22:48 2004 with key 0x93B84C15.
 Visit my photo gallery at http://bloodgate.com/photos/
 PGP key on http://bloodgate.com/tels.asc or per email.

 "Yeah, baby, yeah!"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)
Comment: When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl.

iQEVAwUBQBfwaXcLPEOTuEwVAQGeewf+OYDT1UbWDfAes1WAzfQtb1DGtMxrUxpz
UxOUywUwnuiZrn3A062fARpogVEYZhFLXheWakFn3NGRd7QAqkHItrdvmfEMGdHy
EZDahTD4bjdPmxaUaPxzeo8NLnYjhDa5TwfbPNDQiLL2qKNBzHz2CM3jTtnLMEls
oaI7rEtopBynUfIgzuP7ksK3kxGsziSHfncS57GpMzSxxR3wANZqCE56Qw40S1EE
oRa1AHPTpi4+1rYQwIBcGtsfs3u8Tt8DlXQ7YyJLdMPR68by1zA4BXiswoJPY8Po
M9aboXBZ/F9D4f97wb/zhcz0aAGx5XNuByViEwcee2zJW09nf4tpsw==
=xXUe
-----END PGP SIGNATURE-----


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About