Ticket #230 (assigned defect)

Opened 7 months ago

Last modified 7 months ago

changed behavior when push function object in r3021?

Reported by: yichun Assigned to: bgranger (accepted)
Priority: normal Milestone:
Component: ipython1 Version:
Severity: normal Keywords:
Cc:

Description

With r2914, when a function object is pushed into engines, I get really the same function object on engines:

In [31]: runfunc
Out[31]: <function do_submit_func at 0x888033c>

n [33]: rc.execute(1, "print runfunc")
Out[33]: 
<Results List>
[1] In [46]: print runfunc
[1] Out[46]: <function runfunc at 0xb4f49d4c>

However, the newest r3021 either doesn't push function objects at all, or push them as a ipython1.kernel.pickleutil.CannedFunction? object which cannot be called directly:

In [32]: rc.execute(13, "print runfunc")
Out[32]: 
<Results List>
[13] In [66]: print runfunc
[13] Out[66]: <ipython1.kernel.pickleutil.CannedFunction object at 0x907b70c>

Is this a planned feature or a bug? it looks to me that the old behavior is more pleasant and easy to use.

Change History

02/15/08 19:18:10 changed by yichun

  • owner changed from fperez to bgranger.
  • component changed from chainsaw to ipython1.

(follow-up: ↓ 3 ) 02/15/08 22:06:57 changed by bgranger

  • status changed from new to assigned.

Starting in r3012, push and pull cannot be used for moving functions to engines and back. Instead, there are new dedicated methods in the interface (pushFunction/pullFunction) that should be used for this purpose. This choice was made because the generality of push/pull did not allow for a truly robust handling of functions (which aren't really pickelable). We need to add new logic to push/pull that raises a more informative exception when a user tries to push/pull a function. It should raise something like:

TypeError?("push/pull don't work with functions, use pushFunction/pullFunction instead")

Just a warning, we are getting close to merging in a new set of changes that will change the API in more dramatic ways. Watch the ipython lists for details.

(in reply to: ↑ 2 ) 02/18/08 02:32:50 changed by yichun

Thanks for explanation. Looking forward to see the changes. Would pushFunction/pullFunction be different with push/pull previously we have, in what aspect? Is the closure functions able to be pushed into engines with current implemantation?

Replying to bgranger:

Starting in r3012, push and pull cannot be used for moving functions to engines and back. Instead, there are new dedicated methods in the interface (pushFunction/pullFunction) that should be used for this purpose. This choice was made because the generality of push/pull did not allow for a truly robust handling of functions (which aren't really pickelable). We need to add new logic to push/pull that raises a more informative exception when a user tries to push/pull a function. It should raise something like: TypeError?("push/pull don't work with functions, use pushFunction/pullFunction instead") Just a warning, we are getting close to merging in a new set of changes that will change the API in more dramatic ways. Watch the ipython lists for details.

02/18/08 12:00:05 changed by bgranger

The problem with the general form of push/pull is that you can push/pull a nested python (dict/list/tuple) that had function embedded inside. This is the case that would fail and that we couldn't handle properly. So, the main different with pushFunction/pullFunction is that it only works with top level functions. Closures are still not handled.