Precompiling parser tables

11 views
Skip to first unread message

Pavel Panchekha

unread,
May 23, 2009, 2:15:40 PM5/23/09
to ply-hack
I've written a rather large application with ply as the parser, and it
works pretty well. The problem now is that I now want to redistribute
my application, and thus I want to ship precompiled parser tables.
Now, I'm currently compiling the optimized-mode lexer and parser
tables, and I specify what directory the tables are supposed to be.
Now, when I install ply to /usr/local, the program works, but
unfortunately recompiles the tables every time. This isn't too great,
because this can take a few seconds.

Now, if I make the directory that I've specified as outputdir world-
writable (0777), ply will put tables there, but will constantly
recompile them. So it can find the files there, but it isn't using
them.

Do I need to copy over .pyc files over, too? Do I need to pass magic
arguments to ply?

I'm using ply 3.2. If you want to look at the code, you can find it
at:

http://github.com/pavpanchekha/oranj/tree/master

Thank you in advance

Bart Whiteley

unread,
May 23, 2009, 10:23:57 PM5/23/09
to ply-...@googlegroups.com
On Sat, May 23, 2009 at 12:15 PM, Pavel Panchekha
<PavPan...@gmail.com> wrote:
>
> I've written a rather large application with ply as the parser, and it
> works pretty well. The problem now is that I now want to redistribute
> my application, and thus I want to ship precompiled parser tables.
> Now, I'm currently compiling the optimized-mode lexer and parser
> tables, and I specify what directory the tables are supposed to be.
> Now, when I install ply to /usr/local, the program works, but
> unfortunately recompiles the tables every time. This isn't too great,
> because this can take a few seconds.
>
> Now, if I make the directory that I've specified as outputdir world-
> writable (0777), ply will put tables there, but will constantly
> recompile them. So it can find the files there, but it isn't using
> them.
>
> Do I need to copy over .pyc files over, too? Do I need to pass magic
> arguments to ply?
>

I think this has been covered before once or twice on this list. Try
this thread, as well as another thread or two linked from within it:

http://groups.google.com/group/ply-hack/browse_frm/thread/925c8062a9d0513d

Pavel Panchekha

unread,
May 25, 2009, 6:40:43 PM5/25/09
to ply-hack
Wow! That was enormously helpful. Thanks!

One further question: I have the lexer/parser in optimized mode, in
order to increase the startup speed of the program. Is there any way,
past neutering the ply source code, to stop it from writing tables if
not run in optimized mode? IFAIK, the disabled checks in ply give me
much more of a speedup than just hte -O mode. The problem is that when
it tries to write the tables, it can't open the files in "w" mode
(they're installed in /usr) and so it crashes. Right now, I have the
code neutered - if it fails to write the tables, it just silently
swallows the exception. This isn't the best solution. Is there a
better one?
> http://groups.google.com/group/ply-hack/browse_frm/thread/925c8062a9d...
Reply all
Reply to author
Forward
0 new messages