Also with some version/implementations of python you can not use dis.dis on builtins or C functions. It will blow up with the same sort of NotImplemented error.
-Chris On Thu, Oct 14, 2010 at 4:49 PM, kirby urner <[email protected]> wrote: > Thanks to all for a fine evening last night. My blogged write-up > linked below.** > > I was sounding pretty confidant that I knew what dis.dis would do on > IronPython: spit out IL byte codes right? > > I just tested that hypothesis. But first, the CPython version: > > IDLE 2.6.6 >>>> def f(x): return 2*pow(x,3) + 5*pow(x,2) + 1 > >>>> import dis >>>> dis.dis(f) > 1 0 LOAD_CONST 1 (2) > 3 LOAD_GLOBAL 0 (pow) > 6 LOAD_FAST 0 (x) > 9 LOAD_CONST 2 (3) > 12 CALL_FUNCTION 2 > 15 BINARY_MULTIPLY > 16 LOAD_CONST 3 (5) > 19 LOAD_GLOBAL 0 (pow) > 22 LOAD_FAST 0 (x) > 25 LOAD_CONST 1 (2) > 28 CALL_FUNCTION 2 > 31 BINARY_MULTIPLY > 32 BINARY_ADD > 33 LOAD_CONST 4 (1) > 36 BINARY_ADD > 37 RETURN_VALUE >>>> > > And now for something completely different.... > > IronPython 2.6.1 (2.6.10920.0) on .NET 4.0.30319.1 > Type "help", "copyright", "credits" or "license" for more information. >>>> 6+6 > 12 >>>> import dis >>>> def f(x): return 2*pow(x,3) + 5*pow(x,2) + 1 > ... >>>> dis.dis(f) > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "C:\Program Files (x86)\IronPython 2.6 for .NET > 4.0\Lib\dis.py", line 42, in disassemble > File "C:\Program Files (x86)\IronPython 2.6 for .NET > 4.0\Lib\dis.py", line 64, in disassemble > File "C:\Program Files (x86)\IronPython 2.6 for .NET > 4.0\Lib\dis.py", line 183, in findlinestarts > NotImplementedError > > I should do some reading obviously. It looks like it almost worked, > but looks can be deceiving. > > See ya'll on chat maybe, > > Kirby > > ** http://controlroom.blogspot.com/2010/10/ppug-20101012.html > > PS: next PPUG I could do a lightning talk on what I'm up to with PSF a > little. Here's some documentation. > > http://mail.python.org/pipermail/edu-sig/2010-October/010092.html > > For kids, I prefer Akbar font version: > http://www.flickr.com/photos/17157...@n00/5079860554/ > http://www.flickr.com/photos/17157...@n00/5079860510/ > > It's partly that Pycon / Havana I'm thinking about, also Pycon / Tehran. > Anyone going to Python / Ukraine? Not me. Vilnius was great > though (a EuroPython, not a Pycon). > > Or I could do 5 mins on Martian Math, which I shared through > Reed College this summer. > > http://www.4dsolutions.net/satacad/martianmath/toc.html > (lotsa Python + VPython) > > Michelle: +1 on health tips / diet including the esoteric stuff. :) > This is a vital branch of geekology, per this new O'Reilly title: > http://www.flickr.com/photos/17157...@n00/4965449134/in/set-72157624771928073/ > _______________________________________________ > Portland mailing list > [email protected] > http://mail.python.org/mailman/listinfo/portland > _______________________________________________ Portland mailing list [email protected] http://mail.python.org/mailman/listinfo/portland
