On Thu, Aug 26, 2010 at 10:26 AM, Richard Purdie <[email protected]> wrote:

> On Thu, 2010-08-26 at 10:13 -0700, Chris Larson wrote:
> >
> >
> > On Thu, Aug 26, 2010 at 10:10 AM, Richard Purdie <[email protected]>
> > wrote:
> >         On Thu, 2010-08-26 at 08:30 -0700, Chris Larson wrote:
> >         >
> >         >
> >         > On Thu, Aug 26, 2010 at 7:56 AM, Richard Purdie
> >         <[email protected]>
> >         > wrote:
> >
> >
> >         >         I've written a different dedent_python()
> >         implementation which
> >         >         takes
> >         >         0.12s for the same workload so python_parse is now
> >         12s.
> >         >
> >         >         This brings us to being 4 times slower. So still not
> >         good but
> >         >         better.
> >         >
> >         >
> >         > Interesting, is your version of dedent_python available
> >         somewhere?
> >
> >
> >         Its horrible compared to the other version but yes:
> >
> >
> http://git.pokylinux.org/?p=poky-contrib.git;a=blobdiff;f=bitbake/lib/bb/rptest.py;h=9a5f2b8e536c4d87a55f2141a0ebbbe6c5d5a44d;hp=a585dc10f21dd5d6b0dda4b21eb32ee64c2f2242;hb=94d212ceb2ae2865ed83d3dee6f74ad90006c1d6;hpb=c54136d18fe6c733a9b3b50332415c0b157054a
> >
> >
> > This will break it (I tried with textwrap before moving to the
> > tokenizing method):
> >
> >
> > def foo():
> >     """Foo
> > bar baz"""
>
> You'll note I also tried textwrap() before abandoning it :)
>

I noticed :)

We can save the set of whitespace characters and just replace exact
> matches. This will break the following:
>
> def foo():
>    """Foo
>    bar baz"""
>
> as it will remove whitespace from within the quotes but apart from that
> it should do the job?
>

Yeah, I thought about that too.  Might be the best we can do.  That said,
all we need to do is *compile* the thing, it only has to be correct
syntactically.  In bitbake, it shoves this python string inside of a
function.  We could always do the same.  compile "def foo():\n%s" % codestr
instead.  We'd get the same information back, as we just need to traverse
the ast, which will still be there, just under a function definition node :)
-- 
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
_______________________________________________
Bitbake-dev mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/bitbake-dev

Reply via email to