[IronPython] Performance concerns with mail merge
dinov at exchange.microsoft.com
Tue Sep 19 00:21:21 CEST 2006
It sounds like you want the PythonEngine.CreateMethod API. This allows you to create a delegate that you can call from C# repeatedly w/o any recompilation happening. If you want to swap this out w/ a different delegate you can just call CreateMethod again and update your table of delegates.
The way this works is you give it a delegate type (via the generic parameter) and then you give it a body of code (minus the function declaration) and optionally argument names - incase you're not happy w/ the names the delegate has. It'll return an instance of the delegate type to you, and you can call it from your try block. The 1.0 release includes a .chm which includes full documentation on the API as well.
>From there it's just up to you to decide how to invalidate your delegates that you hold a reference to and request a new delegate. When you release the reference to the delegate the memory associated w/ the code will be released as well.
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of David C
Sent: Monday, September 18, 2006 3:10 PM
To: users at lists.ironpython.com
Subject: [IronPython] Performance concerns with mail merge
We have a mail merge engine. We wish to have the option of blessing mail merge fields (say <##FirstName##>) with the ability to do string formatting, such as proper casing, all caps, date formatting, and such. And the idea is while the mail merge engine is compiled C# code, we are hoping to leverage the dynamic nature of ironpython to allow business analysts and other staff to bless these mail merge fields with dynamic behaviors at a later date--through scripting. We imagine the signature of such a "filter" would go something like:
protected string Filter_SomeBase32GibberishThatsSafeAlphaNumeric(string dirtyText, Xml filterContext)
string cleanText = "";
// the dynamic part that do something with cleanText, given additional information provided by filterContext xml dom
// as an aside, this source code is checked into the db in raw source code form, until the time it need be used
So far what I have learned is that I can do this in C#, using something like this example:
But we want a ton of performance out of this merge intelligence. We hope whatever was compiled (bytecode), is kepted in a hash tree so that recompilation is not a tax levied on each invocation. There will be many such functions, and we need to invoke it by reference/delegate (storing them in a lookup table).
If we are really really greedy, we would make further requests like it be possible to update a function. To recompile an updated source code to one such instance and call the new updated bytecode.
I have no experience with IronPython in terms of embedding it, and making use of it in such a scenario, and wish to consult the list for any suggestions or feasibility comments you may have. Thank you for your time and big kudos ahead of time for any participation on this.
-- Li-fan chen
Be one of the first to try Windows Live Mail.<http://ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users