develooper Front page | perl.perl5.porters | Postings from March 2003

Re: [PATCH] making Exporter simpler to use

Thread Previous | Thread Next
Fergal Daly
March 30, 2003 09:19
Re: [PATCH] making Exporter simpler to use
Message ID:
On Friday 28 March 2003 20:15, Nicholas Clark wrote:
> Will it make exporting use less memory? IIRC Ilya said that uses
> huge amounts of memory in the structures it generates for Exporter.

No, it's just a convenient way of setting up @EXPORT etc. They'll take exactly 
as much space as they did before.

Attached is a patch that allows you to put array refs in @EXPORT, which allows 
you to take the @ out of @$_ in's

for (values %EXPORT_TAGS) {
  push @EXPORT, @$_;

This means that all the strings in %EXPORT_TAGS aren't duplicated in @EXPORT, 
so should approximately cut the memory use in half.

However some of this benfit is lost when someone specifies a list of symbols 
to import rather than just importing the defaults. This is because, for speed 
purposes, Exporter builds a hash of all the symbols, that looks like

	symbol1 => 1,
	symbol2 => 1,

which is another big memory overhead. The patch below changes this hash to 
look like

	symbol1 => undef,
	symbol2 => undef,

which saves about sizeof(1) * number of symbols but that's probably not much 
compared the size of the hash itself.

These patches doesn't cause any test failures for bleadperl.

These are fairly uninvasive patches, to make more progress I think Exporter 
needs to change a lot,


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About