[PATCH] Re: [Petal] Fergal's work / suggestions

Fergal Daly fergal at esatclear.ie
Thu Jun 19 14:03:54 BST 2003


On Thursday 19 June 2003 11:47, Jean-Michel Hiver wrote:
> Hi List,
> 
> I have applied Fergal's patches and it all worked beautifully. I will be
> releasing Petal 0.94 very soon, which is basically Petal 0.93 + a bunch
> of contributed tests / patches / etc.

Excellent.

By the way, I think CPAN's indexer considers 0.100 to be an earlier release 
than 0.99. I got this from a discussion by the Encode people. They're fast 
approaching 1.99 and trying to release new versions infrequently.

That said, it might be time for Petal 1.001...

> You'd write:
> 
>   use Petal::Fast;
> 
> And that'd be it!

Will do.

> Then when you judge that the module is stable enough, we could merge the
> changes back onto Petal if that's OK with you.

Something that worries me is the speed of using Parse::RecDescent, it's very 
slow to get started and this isn't likely to improve. One way to avoid it is 
not to load the CodeGenerator unless we're going to be generating code. So 
instead of

use Petal::CodeGenerator

we would have

eval "require $CodeGenerator";
confess "Failed to load $CodeGenerator, $@" if $@

just before we use it

So the Parse::RecDescent stuff only happens if the template isn't already in 
the cache.

Just realised, a problem with this is that if Petal does a ->process() while 
inside the Safe compartment then the require will fail, so maybe something 
like

if (not $CodeGeneratorLoaded)
{
	eval "require $CodeGenerator";
	confess "Failed to load $CodeGenerator, $@" if $@;
	$CodeGeneratorLoaded = 1;
}

Not loading the CodeGenerator unless it's needed will boost the speed of all 
standalone scripts, so this is not a bad thing even for people who don't use 
Petal::Fast.

Patch attached,

F
-------------- next part --------------
A non-text attachment was scrubbed...
Name: require.patch
Type: text/x-diff
Size: 2061 bytes
Desc: not available
Url : http://www.email-lists.org/pipermail/petal/attachments/20030619/2dbddb83/require.bin


More information about the Petal mailing list