Re: [Python-Dev] 2.5 slower than 2.4 for some things?

2007-06-12 Thread Christian K
ocean wrote:
>> I've had a report from a user that Plex runs about half
>> as fast in 2.5 as it did in 2.4. In particular, the
>> NFA-to-DFA conversion phase, which does a lot of
>> messing about with dicts representing mappings between
>> sets of states.

That was me.

>> Does anyone in the Ministry for Making Python Blazingly
>> fast happen to know of some change that might have
>> pessimised things in this area?
> 
> Hello, I investigated. On my environment, consumed time is
> 
> E:\Plex-1.1.5>py24 plex_test2.py
> 0.71065668
> 
> E:\Plex-1.1.5>py25 plex_test2.py
> 0.92131335
> 
> And after I applied this patch to Plex/Machines, (make `Node' new style
> class)
> 
> 62c62
> < class Node:
> ---
>> class Node(object):
> 
> E:\Plex-1.1.5>py24 plex_test2.py
> 0.40122888
> 
> E:\Plex-1.1.5>py25 plex_test2.py
> 0.350999832153
> 

Nice!.

Meanwhile I tried to replace the parsing I did with Plex by re.Scanner. And
again there is a remarkable speed difference. Again python2.5 is slower:

try:
from re import Scanner
except:
from sre import Scanner

pars = {}
order = []
count = 0

def par(scanner,name):
global count, order, pars

if name in ['caller','e','pi']:
return name
if name not in pars.keys():
pars[name] = ('ns', count)
order.append(name)
ret = 'a[%d]'%count
count += 1
else:
ret = 'a[%d]'%(order.index(name))
return ret

scanner = Scanner([
(r"x", lambda y,x: x),
(r"[a-zA-Z]+\.", lambda y,x: x),
(r"[a-z]+\(", lambda y,x: x),
(r"[a-zA-Z_]\w*", par),
(r"\d+\.\d*", lambda y,x: x),
(r"\d+", lambda y,x: x),
(r"\+|-|\*|/", lambda y,x: x),
(r"\s+", None),
(r"\)+", lambda y,x: x),
(r"\(+", lambda y,x: x),
(r",", lambda y,x: x),
])

import profile
import pstats

def run():
arg = '+amp*exp(-(x-pos)/fwhm)'
for i in range(100):
scanner.scan(arg)

profile.run('run()','profscanner')
p = pstats.Stats('profscanner')
p.strip_dirs()
p.sort_stats('cumulative')
p.print_stats()


Christian

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] csv changed from python 2.4 to 2.5

2007-06-25 Thread Christian K
Hi,

I could not find documentation of the following change in python2.5. What is the
reason for that?

Python 2.4.4 (#2, Apr 12 2007, 21:03:11)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import csv
>>> d=csv.get_dialect('excel')
>>> d.delimiter = ','
>>>

[EMAIL PROTECTED]:/media/hda6/home/ck/prog/peak-o-mat/trunk$ python2.5
Python 2.5.1 (r251:54863, May  2 2007, 16:56:35)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import csv
>>> d=csv.get_dialect('excel')
>>> d.delimiter = ','
Traceback (most recent call last):
  File "", line 1, in 
TypeError: readonly attribute
>>>

the following however works:

Python 2.5.1 (r251:54863, May  2 2007, 16:56:35)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import csv
>>> d = csv.excel
>>> d.delimiter = ','
>>>


Christian

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] csv changed from python 2.4 to 2.5

2007-06-27 Thread Christian K
[EMAIL PROTECTED] wrote:
> Christian> I could not find documentation of the following change in
> Christian> python2.5. What is the reason for that?
> 
> Without looking through the change history for the module it's unclear to me
> why that would have changed.  The thing that changed is that the get_dialect
> call now returns a _csv.Dialect object instead of an instance of the
> csv.excel class:
> 
> % python2.4
> Python 2.4.1 (#3, Jul 28 2005, 22:08:40) 
> [GCC 3.3 20030304 (Apple Computer, Inc. build 1671)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import csv
> >>> d = csv.get_dialect("excel")
> >>> d
> 
> 
> % python
> Python 2.6a0 (trunk:54264M, Mar 10 2007, 15:19:48) 
> [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import csv
> >>> d = csv.get_dialect("excel")
> >>> d
> <_csv.Dialect object at 0x137fac0>
> 
> Please submit a bug report on SourceForge.
> 

Ok. Done.

Christian

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com