Archive for the ‘IronPython’ Category

More Spreadsheet Innovation

Saturday, July 14th, 2007

Readers are probably aware how fond I am of spreadsheets as a tool for rapidly prototyping applications. Here’s another implementation of spreadsheets based around IronPython, but addresses issues like shared updates.

Warning: os.path.join surprising behaviour

Tuesday, June 19th, 2007

>>> os.path.join("/a/b/c", "/d/e/f")
"/d/e/f"

This can be a problem if “/d/e/f” comes from an untrusted source.

As a safety measure, avoid using os.path.join in your web applications, roll your own and call it “safe_join”. You will sleep better.

Embedding IronPython - C# Calling Python Script Part 1

Friday, June 8th, 2007

Embedding IronPython is quite trivial and is documented here.

You can call functions in the embedded python module by
(1) retrieving the function using Evaluate()
(2) then apply the function using the Call() method

using (IronPython.Hosting.PythonEngine engine
  = new IronPython.Hosting.PythonEngine())
{
  engine.Execute(@"
  def foo(a, b):
    return a+b*2");

  // (1) Retrieve the function
  IronPython.Runtime.Calls.ICallable foo
   = (IronPython.Runtime.Calls.ICallable) engine.Evaluate("foo");

  // (2) Apply function
  object result = foo.Call(3, 25);
}

The ICallable.Call method can only be called varargs-style, and can’t be called using keyword arguments.
(This is probably a bug.)

Call(params object[] args)

To use keyword arguments, you’ll need to cast the function into PythonFunction.

Note:
Unfortunately, Python classes aren’t CLR classes, and couldn’t be accessed directly or subclassed by C# by referencing a built assembly. You’ll have to go through the hosting interfaces to get an instance of the class.

Strongtalk Is Open Sourced

Wednesday, September 13th, 2006

Strongtalk is a version of Smalltalk developed with speed in mind. It was developed by a startup but the company was bought by Sun to work on the JVM before Strongtalk was productized.

Strongtalk allows optional static typic. Interestingly, the static typing information is not used by the optimizer to produce fast code. Instead, Strongtalk uses run-time profiling, which is now adopted in the Hotspot JVM.

Given the similarities between Smalltalk and Python, I guess one can build a very speedy Python in Strongtalk.

However, it is not a particularly useful strategic move for Python. Python’s weakness right now is in its library size (true!) in comparison to the Java and .Net framework libraries.

On the other front, it’s not competitive against PHP’s shared-nothing architecture, which makes virtual hosting attractive. Strategically, Python’s full potential lies dormant until it’s VM and library is retooled to support locking down, and purging of modules so that one VM can be recycled for use by many requests.

Tell me what you think!

Via Avi Bryant

technorati tags:, ,

IronPython on CherryPy

Saturday, May 27th, 2006

I didn’t realize there is Planet CherryPy. Do check it out, as several authors aren’t aggregated on Planet Python.

Incidentally, there are initial reports of success running CherryPy on IronPython. I think this is a great idea, if it means being able to access some really cool components that are available on the 3rd party .Net platform.

What do you think? Will this make a difference to people when selecting web frameworks?