[IronPython] getframe and __file__

Dino Viehland dinov at microsoft.com
Mon Nov 17 18:40:16 CET 2008


This is definitely possible but it'd be a hack and would have some odd corner cases.  In terms of Python the problem here is we could find out the func_code (MethodInfo's in .NET speak) but not the actual function object.  We could maintain a mapping which would let us get back to function objects but there'd be some cases where we'd pick the wrong one.  It'd also be really slow because .NET stack traces are slow.  If we maintain this at runtime it won't be much different than my existing frame prototype.

As for IronPython extensions module...  If you mean on startup if there was a way you could add your own built-in modules you can.  Just drop any DLL into a directory called DLLs below ipy.exe and we'll do a clr.AddReference to all of those DLLs.  If any of those DLLs have one or more PythonModuleAttribute's defined we'll add those to the list of built-in modules.

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of orip
Sent: Sunday, November 16, 2008 11:53 PM
To: users at lists.ironpython.com
Subject: Re: [IronPython] getframe and __file__

That certainly fits my use case.
It would be cool to check for an "IronPython Extensions" module and
use it if available.

On Nov 16, 7:39 pm, Michael Foord <fuzzy... at voidspace.org.uk> wrote:
> Hello guys,
>
> Around 90% of the uses for sys._getframe that I've seen are to find out
> the calling module, by accessing __file__ in the calling frame globals.
> I just wondered if it would be any cheaper to just track this
> information and fake out the frame objects so that this use case is met?
>
> The answer is probably no as it basically requires tracking the same
> information (and I guess that the performance hit comes mainly from the
> thread locals and frame tracking rather than from building the Python
> stack frame objects) - but on the off-chance that it might be cheaper
> (obviously only the tracking needs to be implemented - everything else
> can be built on demand) I thought I would throw it out there.
>
> Michael
>
> --http://www.ironpythoninaction.com/
>
> _______________________________________________
> Users mailing list
> Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list