Re: relative speed of incremention syntaxes (or "i=i+1" VS "i+=1")

2011-08-21 Thread Andreas Löscher
Am Sonntag, den 21.08.2011, 19:38 -0400 schrieb Terry Reedy: > On 8/21/2011 7:17 PM, Andreas Löscher wrote: > > Am Sonntag, den 21.08.2011, 14:52 -0400 schrieb Roy Smith: > >> In article, > >> Christian Heimes wrote: > >> > >>> Am 21.08.2011 19

Re: relative speed of incremention syntaxes (or "i=i+1" VS "i+=1")

2011-08-21 Thread Andreas Löscher
Am Sonntag, den 21.08.2011, 12:53 -0700 schrieb Laurent: > > With 64 bit 3.2.2 on my Win 7 Pentium, the difference was 4% and with > > floats (0.0 and 1.0), 6% > > For floats it is understandable. But for integers, seriously, 4% is a lot. I > would never have thought an interpreter would have di

Re: relative speed of incremention syntaxes (or "i=i+1" VS "i+=1")

2011-08-21 Thread Andreas Löscher
Am Sonntag, den 21.08.2011, 14:52 -0400 schrieb Roy Smith: > In article , > Christian Heimes wrote: > > > Am 21.08.2011 19:27, schrieb Andreas Lscher: > > > As for using Integers, the first case (line 1319 and 1535) are true and > > > there is no difference in Code. However, Python uses a huge s

Re: relative speed of incremention syntaxes (or "i=i+1" VS "i+=1")

2011-08-21 Thread Andreas Löscher
> What the precise difference (semantics and speed) is between the > BINARY_ADD and INPLACE_ADD opcodes, I dunno. Look in the Python source > code or maybe someone knows it from memory :-) > > Irmen > from Python/ceval.c: 1316case BINARY_ADD: 1317w = POP(); 1318

Re: Some syntactic sugar proposals

2010-11-22 Thread Andreas Löscher
> if x in range(a, b): #wrong! > it feels so natural to check it that way, but we have to write > if a <= x <= b > I understand that it's not a big deal, but it would be awesome to have > some optimisations - it's clearly possible to detect things like that > "wrong" one and fix it in a byt

Re: Serializing functions

2010-06-17 Thread Andreas Löscher
Am Donnerstag, den 17.06.2010, 18:03 +0200 schrieb Andreas Löscher: > Am Donnerstag, den 17.06.2010, 08:18 -0700 schrieb Paul Rubin: > > Matteo Landi writes: > > > I could be wrong, but it seems functions are not marshable objects, is > > > it right? > > >

Re: Serializing functions

2010-06-17 Thread Andreas Löscher
Am Donnerstag, den 17.06.2010, 08:18 -0700 schrieb Paul Rubin: > Matteo Landi writes: > > I could be wrong, but it seems functions are not marshable objects, is > > it right? > > Hmm, you're right, you can marshal code objects, but you can't marshal a > function directly. It's been a while since

Re: Parser

2010-05-06 Thread Andreas Löscher
Am Sonntag, den 02.05.2010, 21:54 +0200 schrieb Andreas Löscher: > Hi, > I am looking for an easy to use parser. I am want to get an overview > over parsing and want to try to get some information out of a C-Header > file. Which parser would you recommend? > > Best, > Andre

Parser

2010-05-02 Thread Andreas Löscher
Hi, I am looking for an easy to use parser. I am want to get an overview over parsing and want to try to get some information out of a C-Header file. Which parser would you recommend? Best, Andreas -- http://mail.python.org/mailman/listinfo/python-list

Re: Code redundancy

2010-04-21 Thread Andreas Löscher
You can do something like this: >>> class A(): pass >>> inst=A() >>> exec(""" ... a=1 ... b=2 ... c=3 ... d=4 ... """) in inst.__dict__ >>> inst.a 1 >>> This executes the Statement in the exec function and uses inst.__dict__ as namespace. But be aware, that this is not recommended. If you mess w

Re: Object serialization: transfer from a to b (non-implemented code on b)

2010-04-15 Thread Andreas Löscher
> import types > import marshal > def a(): pass > > > ... > > > s=marshal.dumps(a.__code__) > f=types.FunctionType(marshal.loads(s), {}) > f > > > > > > > What version of python do you have? If I try your code above I get : > > >>

Re: Object serialization: transfer from a to b (non-implemented code on b)

2010-04-14 Thread Andreas Löscher
Am Mittwoch, den 14.04.2010, 12:37 +0200 schrieb Gabriel Rossetti: > Andreas Löscher wrote: > > Am Mittwoch, den 14.04.2010, 11:33 +0200 schrieb Gabriel Rossetti: > > > >> Paul Rubin wrote: > >> > >>> Gabriel Rossetti writes: > >&

Re: Object serialization: transfer from a to b (non-implemented code on b)

2010-04-14 Thread Andreas Löscher
Am Mittwoch, den 14.04.2010, 11:33 +0200 schrieb Gabriel Rossetti: > Paul Rubin wrote: > > Gabriel Rossetti writes: > > > >> I am trying to serialize a function, class, etc and transfer it > >> > > > > You mean the actual code? You have to use marshal rather than pickle, > > the Python ve

Re: Castrated traceback in sys.exc_info()

2010-03-25 Thread Andreas Löscher
> As you see, the traceback only starts from function c, which handles the > exception. > It doesn't show main(), a() and b(), which might however be (and are, in > my case) critical to diagnose the severity of the problem (since many > different paths would lead to calling c()). This results

Re: staticmethod and setattr

2010-03-15 Thread Andreas Löscher
Am Montag, den 15.03.2010, 05:42 -0700 schrieb Michael.Lausch: > On Mar 15, 11:40 am, Steven D'Aprano cybersource.com.au> wrote: > > On Mon, 15 Mar 2010 01:43:02 -0700, Michael.Lausch wrote: > > > Hi, > > > > > I managed to get confused by Python, which is not such an easy task. > > > > > The prob

Re: Unexpected python exception

2009-11-17 Thread Andreas Löscher
Python searches for Variables not only in local or global scoop but also in __builtins__. If you do something like __builtins__.os = os, than this variable should be accessible global. If you then write something like: def B(): os.stat("/") import os Python recognises on compile

Re: Unexpected python exception

2009-11-17 Thread Andreas Löscher
Hi, unfortunatley I cannot reproduce your error. Which Python Version do you use? The expected case in this scenario is that the exception is thrown, as you import os in A() where it is stored in the local namespace of the function. I tested it with Python 2.4, 2.5 and 2.6 and in both cases an ex

YIELD_VALUE Byte Code

2009-11-17 Thread Andreas Löscher
Hi, I am not sure if this is the right newsgroup, so if not don't hesitate to tell me. I am developed a Python to C compiler, so that Byte Code files automatically can be translated into C Extension Modules. (And it works pretty well --> http://www.coremountains.com/products/bytecoat/) While deve