In CPython, the runtime will look for a .pyc file corresponding to any .py file
it's asked to access, and its contents are used if the .pyc file's timestamp is
later than that of the .py file. The .pyc file contents aren't native code,
but in theory things are (at least a little bit) faster when the .pyc exists as
the syntax analysis (and some other work) has already been done.
As I understand IP's internals, the process of compiling is explicitly in two
steps -- syntax analysis (resulting in an AST being built) and IL code
generation. Code generation is sometimes (often?) delayed until a method is
actually called, with the dual advantages of (a) being able to generate code
that can optimize appropriately for the actual parameters used, and (b)
avoiding the work of generating code for methods that are never called.
Are there any plans to do something so that frequently-used (imported) code can
be at least syntax-checked once, even if code isn't to be generated until
runtime? A mechanism that produced a file holding a representation of the AST
would be the equivalent of the .pyc file mechanism; would an optimization like
that be useful for IP, and if so is it planned?
I can see producing an assembly from the AST file, where calls to every method
would result in the code generation step being executed for that method. (That
perhaps could be the default for the format of the file holding the AST, with
the AST a resource in the assembly.) An additional step could invoke the code
generator for particular methods with particular argument type specs and build
an assembly that already has type-specific IL implementations of some methods.
I'm thinking that a "plain AST" assembly would have the equivalent of the C#
method
object MethodName(params object[] args)
for each method. The IL for that method would call a routine in the runtime to
generate code if it hadn't been generated before, then call it. With work on
the part of the developer (possibly directed by the contents of a file
generated by tracing the execution of the code), there would be other methods
with specific relevant signatures, and type-specific code generated for those.
Is this in line with what's being discussed? Where is the discussion taking
place?
Thanks for listening.
J. Merrill / Analytical Software Corp
_______________________________________________
users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com