Re: pypy and ctypes

2013-11-14 Thread Peter Chant
On 11/14/2013 03:13 PM, Neil Cerutti wrote: On 2013-11-14, Peter Chant p...@petezilla.co.uk wrote: Or is it that - if I keep the code as simple as possible, PyPy is about as fast as you can get? PyPy profiles your code as it runs and creates, using a just-in-time compiler, highly optimized

pypy and ctypes

2013-11-13 Thread Peter Chant
I'm looking to speed up some python code. Replacing the python interpreter with pypy was impressive. I noted that use of ctypes (in cython?), specifically declaring variables as below, was reported as giving a useful result: cdef float myvar cdef int i under cython can provide a useful

Convert QStingList to Python list

2010-11-27 Thread Peter Chant
The following code generates a QStringList: fileNames = QFileDialog.getOpenFileNames(None,Chose raw file,.,) Printing it: print Files selected +QStringList(fileNames) Results in: TypeError: cannot concatenate 'str' and 'QStringList' objects Any idea how to convert a QStingList into a python

Re: Convert QStingList to Python list

2010-11-27 Thread Peter Chant
Peter Otten wrote: Try it out yourself in the interactive interpreter. Here's a sample session: Peter, thanks. I've got some way to go with python and have only just started looking at Qt, your help has been very useful. Pete -- http://www.petezilla.co.uk --

Re: Checking that 2 pdf are identical (md5 a solution?)

2010-07-24 Thread Peter Chant
rlevesque wrote: Is there a way to compare 2 pdf files generated at different time but identical in every other respect and validate by program that the files are identical (for all practical purposes)? I wonder, do the PDFs have a timestamp within them from when they are created? That

Python, PIL and 16 bit per channel images

2010-01-25 Thread Peter Chant
Does anyone know whether PIL can handle 16 bit per channel RGB images? PyPNG site (http://packages.python.org/pypng/ca.html) states PIL uses 8 bits per channel internally. Thanks, Pete -- http://www.petezilla.co.uk -- http://mail.python.org/mailman/listinfo/python-list

Re: how to generate random numbers that satisfy certain distribution

2010-01-23 Thread Peter Chant
thinke365 wrote: such as uniform distribution, Normal distribution or poisson distribution. is there any package that can be used to generate such random numbers. I remeber being told that adding up 12 random numbers in the range 0-1 (which is what most computer random number genertors at

Re: Perl to Python conversion

2009-12-09 Thread Peter Chant
Martin Schöön wrote: Hence, are there any Perl to Python converters? So far I have only found bridgekeeper which really is (was?) consultancy. Apart from that I only find people recommending a manual re-write. Any thoughts/recommendations? Voice of almost no experience. I once ran a

Re: python simply not scaleable enough for google?

2009-11-11 Thread Peter Chant
Terry Reedy wrote: I can imagine a day when code compiled from Python is routinely time-competitive with hand-written C. In my very limited experience it was very informative programming in C for PIC microcontrollers and inspecting the assembly code produced. If I just threw together loops

Re: Simple audio

2009-10-21 Thread Peter Chant
Simon Forman wrote: Someone else will probably give you better advice, but have you looked at pygame? IIRC they have a pretty simple audio playback api. I'm using pygame for something else. Will it work without the graphics side being used? I suppose trying it is the best plan! Pete --

Simple audio

2009-10-20 Thread Peter Chant
What are recommendations for simple audio playback? I want to play back on linux (Slackware), which uses alsa. There seem to be many ways - but some are a couple of years old and won't compile, like pymedia, or seem not widely used and need pulseaudio (swmixer) which I have not installed. I

Re: Setuptools - help!

2009-08-07 Thread Peter Chant
Robert Kern wrote: You need to put main.py into the pphoto package. $ mkdir pphoto/ $ mv main.py pphoto/ $ touch pphoto/__init__.py Thanks, it worked. Any ideas how to run the resulting scripts without installing or running as root? Pete -- http://www.petezilla.co.uk --

Setuptools - help!

2009-08-06 Thread Peter Chant
Chaps, any ideas, I'm floundering - I don't quite get it. I have the following files, setup.py and main.py in a directory pphoto: # more setup.py from setuptools import setup, find_packages setup( name = Pphoto, version = 0.1, packages = find_packages(), # other arguments

Building / making an application

2009-08-02 Thread Peter Chant
What is a good way to do this? There are instructions on making modules at: http://docs.python.org/distutils/setupscript.html however, what do you do if you don't want a module? I'm thinking of where I'd like to split the code into several files and have a build / setup script put it together

Re: Building / making an application

2009-08-02 Thread Peter Chant
Krishnakant wrote: Have you considered creating a deb or rpm package for your application? Most of the documentation for deb or rpm will talk about make files. But even a distutil based python package (with a setup.py) can be made into a deb package. Then the your requirement will be

Re: Building / making an application

2009-08-02 Thread Peter Chant
Diez B. Roggisch wrote: You should consider using setuptools. Then you get an egg that people can install, and you can define console_scripts-entry-points which will be installed into /usr/local/bin or similar locations. Interesting, I think I need to have a play with that. The cross

Python graphics / imaging library

2009-07-18 Thread Peter Chant
Chaps, what's the most appropriate (maintained) graphics library to use? PIL seems to have last been updated in 2006 http://www.pythonware.com/products/pil/ and GD seems to be even older. Don't want to go down a dead end. Pete -- http://www.petezilla.co.uk --

Re: Python graphics / imaging library

2009-07-18 Thread Peter Chant
Michiel Overtoom wrote: Peter Chant wrote: what's the most appropriate (maintained) graphics library to use? PIL seems to have last been updated in 2006 http://www.pythonware.com/products/pil/ and GD seems to be even older. Don't want to go down a dead end. Contrary to organic

Re: Python graphics / imaging library

2009-07-18 Thread Peter Chant
Peter Chant wrote: No, it does not. However, if PIL was updated last in 2006. Python in 2009 has gone to version 3.1. If PIL is compatible with 3.1 then I'm fine. But I don't want to have to stick with Python 2.5 as the rest of the world moves on. BTW, this was not a critisism of PIL

Re: Python graphics / imaging library

2009-07-18 Thread Peter Chant
Max Erickson wrote: More recent months contain updates to the status of 1.1.7, it is headed towards a release. Preliminary tarballs and binaries are available on effbot.org: http://effbot.org/downloads/#imaging http://effbot.org/downloads/#pil Excellent. From a very brief look it seems

PyGame font issues

2009-04-27 Thread Peter Chant
Chaps, I have the following code: if pygame.font: font = pygame.font.Font(None, 36) #font = pygame.font.Font('liberationserif',36) text = font.render(Esc to quit., 1, (10, 10, 10)) textpos = text.get_rect() textpos.centerx = background.get_rect().centerx

Re: Newbie SWMixer / numpy help - AssertionError

2009-02-08 Thread Peter Chant
Robert Kern wrote: snd = swmixer.Sound(data=tone_data) Well, sort of. You probably need to scale your data and convert it to int16 format. It's currently in floating point format. Done and working, thanks. As file was not needed for file=test.wav I assumed the data prefix for data was

Newbie SWMixer / numpy help - AssertionError

2009-02-07 Thread Peter Chant
Hello, I'm a bit of a python newby. I want to play and record sound simultaneously. SWMixer seems able to do this but the examples use WAV files. I'm trying to play a test tone. Can anyone give me a steer as to why this fails? import sys import swmixer import numpy