Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Nick Craig-Wood
John Nagle wrote: > As an example of code that really needs to run fast, but is > speed-limited by Python's limitations, see "tokenizer.py" in > > http://code.google.com/p/html5lib/ > > This is a parser for HTML 5, a piece of code that will be needed > in many places and will proce

How Python Implements "long integer"?

2009-07-05 Thread Pedram
Hello, I'm reading about implementation of long ints in Python. I downloaded the source code of CPython and will read the longobject.c, but from where I should start reading this file? I mean which function is the first? Anyone can help? Thanks Pedram -- http://mail.python.org/mailman/listinfo/py

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Hendrik van Rooyen
"John Nagle" wrote: > Python doesn't have a "switch" or "case" statement, and when > you need a state machine with many states, that makes for painful, > slow code. There's a comment in the code that it would be useful > to run a few billion lines of HTML through an instrumented version > of the

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Steven D'Aprano
On Sat, 04 Jul 2009 20:15:11 -0700, John Nagle wrote: > Paul Rubin wrote: >> John Nagle writes: >>> A dictionary lookup (actually, several of them) for every >>> input character is rather expensive. Tokenizers usually index into a >>> table of character classes, then use the character class i

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Stefan Behnel
John Nagle wrote: > Python doesn't have a "switch" or "case" statement, and when > you need a state machine with many states, that makes for painful, > slow code. Cython has a built-in optimisation that maps if-elif-else chains to C's switch statement if they only test a single int/char variable,

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Paul Rubin
Steven D'Aprano writes: > Okay, we get it. Parsing HTML 5 is a bitch. What's your point? I don't > see how a case statement would help you here: you're not dispatching on a > value, but running through a series of tests until one passes. A case statement switch(x):... into a bunch of constant

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Stefan Behnel
John Nagle wrote: >Here's some actual code, from "tokenizer.py". This is called once > for each character in an HTML document, when in "data" state (outside > a tag). It's straightforward code, but look at all those > dictionary lookups. > > def dataState(self): > data = self.str

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Stefan Behnel
John Nagle wrote: > Paul Rubin wrote: >> John Nagle writes: >>> Python doesn't have a "switch" or "case" statement, and when >>> you need a state machine with many states, that makes for painful, >>> slow code. ... >>> There's a comment in the code that it would be useful >>> to run a few billion

Re: question of style

2009-07-05 Thread Steven D'Aprano
On Sat, 04 Jul 2009 23:17:21 -0700, Paul Rubin wrote: > Steven D'Aprano writes: >> Certain people -- a tiny minority -- keep trying to argue that the >> ability to say "if obj" for arbitrary objects is somehow a bad thing, >> and their arguments seem to always boil down to: "If you write code >>

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Steven D'Aprano
On Sun, 05 Jul 2009 10:12:54 +0200, Hendrik van Rooyen wrote: > Python is not C. John Nagle is an old hand at Python. He's perfectly aware of this, and I'm sure he's not trying to program C in Python. I'm not entirely sure *what* he is doing, and hopefully he'll speak up and say, but whatever

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Steven D'Aprano
On Sun, 05 Jul 2009 01:58:13 -0700, Paul Rubin wrote: > Steven D'Aprano writes: >> Okay, we get it. Parsing HTML 5 is a bitch. What's your point? I don't >> see how a case statement would help you here: you're not dispatching on >> a value, but running through a series of tests until one passes.

Re: Adding an object to the global namespace through " f_globals" is that allowed ?

2009-07-05 Thread Stef Mientki
Terry Reedy wrote: Stef Mientki wrote: hello, I need to add an object's name to the global namespace. The reason for this is to create an environment, where you can add some kind of math environment, where no need for Python knowledge is needed. The next statement works, but I'm not sure if it

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Paul Rubin
Steven D'Aprano writes: > Yes, I'm aware of that, but that's not what John's code is doing -- he's > doing a series of if expr ... elif expr tests. I don't think a case > statement can do much to optimize that. The series of tests is written that way because there is no case statement available

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Stefan Behnel
Stefan Behnel wrote: > John Nagle wrote: >>Here's some actual code, from "tokenizer.py". This is called once >> for each character in an HTML document, when in "data" state (outside >> a tag). It's straightforward code, but look at all those >> dictionary lookups. >> >> def dataState(self

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Stefan Behnel
Paul Rubin wrote: > Steven D'Aprano writes: >> Yes, I'm aware of that, but that's not what John's code is doing -- he's >> doing a series of if expr ... elif expr tests. I don't think a case >> statement can do much to optimize that. > > The series of tests is written that way because there is n

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Paul Rubin
Stefan Behnel writes: > > # Keep a charbuffer to handle the escapeFlag > > if self.contentModelFlag in\ > > (contentModelFlags["CDATA"], contentModelFlags["RCDATA"]): > Is the tuple > (contentModelFlags["CDATA"], contentModelFlags["RCDATA"]) > constant? If that is t

Re: Multi thread reading a file

2009-07-05 Thread Lawrence D'Oliveiro
In message <025ff4f1$0$20657$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: > On Sun, 05 Jul 2009 12:12:22 +1200, Lawrence D'Oliveiro wrote: > >> In message >> <1beffd94-cfe6-4cf6-bd48-2ccac8637...@j32g2000yqh.googlegroups.com>, ryles >> wrote: >> >> # Oh... yeah. I really *did* want '

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Paul Rubin
Stefan Behnel writes: > > The series of tests is written that way because there is no case > > statement available. It is essentially switching on a bunch of > > character constants and then doing some additional tests in each > > branch. > Although doing some of the tests first and then checking

Re: Is code duplication allowed in this instance?

2009-07-05 Thread Lawrence D'Oliveiro
In message , Klone wrote: > So in this scenario is it OK to duplicate the algorithm to be tested > within the test codes or refactor the method such that it can be used > within test codes to verify itself(??). I think you should be put on the management fast-track. -- http://mail.python.org/ma

Re: How Python Implements "long integer"?

2009-07-05 Thread Mark Dickinson
On Jul 5, 8:38 am, Pedram wrote: > Hello, > I'm reading about implementation of long ints in Python. I downloaded > the source code of CPython and will read the longobject.c, but from > where I should start reading this file? I mean which function is the > first? I don't really understand the que

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Stefan Behnel
Paul Rubin wrote: > Stefan Behnel writes: >>> The series of tests is written that way because there is no case >>> statement available. It is essentially switching on a bunch of >>> character constants and then doing some additional tests in each >>> branch. >> Although doing some of the tests fir

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Stefan Behnel
Paul Rubin wrote: > Stefan Behnel writes: >>> # Keep a charbuffer to handle the escapeFlag >>> if self.contentModelFlag in\ >>> (contentModelFlags["CDATA"], contentModelFlags["RCDATA"]): >> Is the tuple >> (contentModelFlags["CDATA"], contentModelFlags["RCDATA"]) >> c

Re: question of style

2009-07-05 Thread Paul Rubin
Steven D'Aprano writes: > > Yes, it saves a few keystrokes to say "if x:" instead of "if > > len(x)==0:" or even "if bool(x):", > > It's not about saving keystrokes -- that's a furphy. It's about > encapsulation. Objects are in a better position to recognise when they > are "something" (true)

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Paul Rubin
Stefan Behnel writes: > You may notice that the creation of this exact tuple appears in almost all > if the conditionals of this method. So it is part of the bottleneck. I don't think so. The tuple is only created when the character has already matched, and for the vast majority of the chars in

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Stefan Behnel
Paul Rubin wrote: > Stefan Behnel writes: >> You may notice that the creation of this exact tuple appears in almost all >> if the conditionals of this method. So it is part of the bottleneck. > > I don't think so. The tuple is only created when the character has > already matched, and for the vas

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Paul McGuire
On Jul 5, 3:12 am, "Hendrik van Rooyen" wrote: > > Use a dispatch dict, and have each state return the next state. > Then you can use strings representing state names, and > everybody will be able to understand the code. > > toy example, not tested, nor completed: > > protocol = {"start":initialis

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Stefan Behnel
John Nagle wrote: >Here's some actual code, from "tokenizer.py". This is called once > for each character in an HTML document, when in "data" state (outside > a tag). It's straightforward code, but look at all those > dictionary lookups. > > def dataState(self): > data = self.str

Re: How Python Implements "long integer"?

2009-07-05 Thread Pedram
On Jul 5, 1:57 pm, Mark Dickinson wrote: > On Jul 5, 8:38 am, Pedram wrote: > > > Hello, > > I'm reading about implementation of long ints in Python. I downloaded > > the source code of CPython and will read the longobject.c, but from > > where I should start reading this file? I mean which funct

Re: question of style

2009-07-05 Thread Lie Ryan
Paul Rubin wrote: > Steven D'Aprano writes: >> "if len(x) == 0" is wasteful. Perhaps I've passed you a list-like >> iterable instead of a list, and calculating the actual length is O(N). > > That doesn't happen in any of Python's built-in container types. I > could see some value to having a g

Re: Is code duplication allowed in this instance?

2009-07-05 Thread David Robinow
On Sun, Jul 5, 2009 at 5:54 AM, Lawrence D'Oliveiro wrote: > In message c1d1c62d6...@y17g2000yqn.googlegroups.com>, Klone wrote: > >> So in this scenario is it OK to duplicate the algorithm to be tested >> within the test codes or refactor the method such that it can be used >> within test codes t

Re: PSP Caching

2009-07-05 Thread Johnson Mpeirwe
Thanks Simon, I got around this behavior by adding "MaxRequestsPerChild 1" (default value of this is 0) to my httpd.conf to limit the number of requests a child server process will handle before it dies but I think it is important to keep it 0 in production environment. Regards, Johnson On Fri,

ANN: A new version of the Python module which wraps GnuPG has been released.

2009-07-05 Thread Vinay Sajip
A new version of the Python module which wraps GnuPG has been released. What Does It Do? The gnupg module allows Python programs to make use of the functionality provided by the Gnu Privacy Guard (abbreviated GPG or GnuPG). Using this module, Python programs can encrypt and decryp

Re: How Python Implements "long integer"?

2009-07-05 Thread Mark Dickinson
On Jul 5, 1:09 pm, Pedram wrote: > Thanks for reply, > Sorry I can't explain too clear! I'm not English ;) That's shocking. Everyone should be English. :-) > But I want to understand the implementation of long int object in > Python. How Python allocates memory and how it implements operations

Re: question of style

2009-07-05 Thread Paul Rubin
Steven D'Aprano writes: > > I wouldn't say Python's None is terrible,... > No, wait, I tell I lie... re.search() sometimes bites me, because > sometimes it returns None and sometimes it returns a matchobject and I > don't use re often enough to have good habits with it yet. re is a common sourc

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Hendrik van Rooyen
"Steven D'Aprano" wrote: >On Sun, 05 Jul 2009 10:12:54 +0200, Hendrik van Rooyen wrote: > >> Python is not C. > >John Nagle is an old hand at Python. He's perfectly aware of this, and >I'm sure he's not trying to program C in Python. > >I'm not entirely sure *what* he is doing, and hopefully he'

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Hendrik van Rooyen
"Paul Rubin" wrote: > The series of tests is written that way because there is no case > statement available. It is essentially switching on a bunch of > character constants and then doing some additional tests in each > branch. > > It could be that using ord(c) as

Re: How Python Implements "long integer"?

2009-07-05 Thread Pedram
On Jul 5, 5:04 pm, Mark Dickinson wrote: > That's shocking.  Everyone should be English. :-) Yes, I'm trying :) > I'd pick one operation (e.g., addition), and trace through the > relevant functions in longobject.c.  Look at the long_as_number > table to see where to get started. > > In the case

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Lino Mastrodomenico
2009/7/5 Hendrik van Rooyen : > I cannot see how you could avoid a python function call - even if he > bites the bullet and implements my laborious scheme, he would still > have to fetch the next character to test against, inside the current state. > > So if it is the function calls that is slowing

Re: How Python Implements "long integer"?

2009-07-05 Thread Pablo Torres N.
On Sun, Jul 5, 2009 at 04:57, Mark Dickinson wrote: > On Jul 5, 8:38 am, Pedram wrote: >> Hello, >> I'm reading about implementation of long ints in Python. I downloaded >> the source code of CPython and will read the longobject.c, but from >> where I should start reading this file? I mean which f

Re: Problems with using queue in Tkinter application

2009-07-05 Thread Icarus
On Jul 4, 11:24 am, Peter Otten <__pete...@web.de> wrote: > Icarus wrote: > > On Jul 4, 3:21 am, Peter Otten <__pete...@web.de> wrote: > >> Icarus wrote: > >> > I'm working on a serial protocol analyzer in python.  We have an > >> > application written by someone else in MFC but we need something t

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Aahz
In article , Hendrik van Rooyen wrote: > >But wait - maybe if he passes an iterator around - the equivalent of >for char in input_stream... Still no good though, unless the next call >to the iterator is faster than an ordinary python call. Calls to iterators created by generators are indeed fast

Python and webcam capture delay?

2009-07-05 Thread jack catcher (nick)
Hi, I'm thinking of using Python for capturing and showing live webcam stream simultaneously between two computers via local area network. Operating system is Windows. I'm going to begin with VideoCapture extension, no ideas about other implementation yet. Do you have any suggestions on how s

[no subject]

2009-07-05 Thread 13139781969
Title: New Page 1 This message was sent using picture-talk messaging service from MetroPCS. (Homer & Marge having sex with Bart Simpson)> (Homer & Marge having sex with Bart Simpson)-- http://mail.python.org/mailman/listinfo/python-list

generation of keyboard events

2009-07-05 Thread RAM
Hi, I need to start an external program and pass the keyboard events like F1,Right arrow key etc to the program..I am trying to use the subprocess module to invoke the external program. I am able to invoke but not able to generate the keyboard events and pass them on to the external progam. Please

Re: question of style

2009-07-05 Thread Steven D'Aprano
On Sun, 05 Jul 2009 03:08:16 -0700, Paul Rubin wrote: > Steven D'Aprano writes: >> > Yes, it saves a few keystrokes to say "if x:" instead of "if >> > len(x)==0:" or even "if bool(x):", >> >> It's not about saving keystrokes -- that's a furphy. It's about >> encapsulation. Objects are in a bette

Re: How Python Implements "long integer"?

2009-07-05 Thread Pedram
Hello again, This time I have a simple C question! As you know, _PyLong_New returns the result of PyObject_NEW_VAR. I found PyObject_NEW_VAR in objimpl.h header file. But I can't understand the last line :( Here's the code: #define PyObject_NEW_VAR(type, typeobj, n) \ ( (type *) PyObject_InitVar(

Re: How Python Implements "long integer"?

2009-07-05 Thread Aahz
In article <6f6be2b9-49f4-4db0-9c21-52062d8ea...@l31g2000yqb.googlegroups.com>, Pedram wrote: > >This time I have a simple C question! >As you know, _PyLong_New returns the result of PyObject_NEW_VAR. I >found PyObject_NEW_VAR in objimpl.h header file. But I can't >understand the last line :( Her

Re: generation of keyboard events

2009-07-05 Thread Tim Harig
On 2009-07-05, RAM wrote: > I need to start an external program and pass the keyboard events like > F1,Right arrow key etc to the program..I am trying to use the > subprocess module to invoke the external program. I am able to invoke > but not able to generate the keyboard events and pass them on

Re: question of style

2009-07-05 Thread Steven D'Aprano
On Sun, 05 Jul 2009 11:37:49 +, Lie Ryan wrote: > Neither python's `if` nor `if` in formal logic is about testing True vs. > False. `if` in python and formal logic receives a statement. The > statement must be evaluatable to True or False, but does not have to be > True or False themselves. It

Re: generation of keyboard events

2009-07-05 Thread Emile van Sebille
On 7/5/2009 8:56 AM RAM said... Hi, I need to start an external program and pass the keyboard events like F1,Right arrow key etc to the program..I am trying to use the subprocess module to invoke the external program. I am able to invoke but not able to generate the keyboard events and pass them

Re: question of style

2009-07-05 Thread Steven D'Aprano
On Sun, 05 Jul 2009 06:12:25 -0700, Paul Rubin wrote: >> There are three natural approaches to (say) re.search() for dealing >> with failure: >> >> (1) return a sentinel value like None; (2) return a matchobject which >> tests False; (3) raise an exception. > > 4. Have re.search return a bool an

Re: How Python Implements "long integer"?

2009-07-05 Thread Pedram
On Jul 5, 8:12 pm, a...@pythoncraft.com (Aahz) wrote: > In article > <6f6be2b9-49f4-4db0-9c21-52062d8ea...@l31g2000yqb.googlegroups.com>, > > > > Pedram   wrote: > > >This time I have a simple C question! > >As you know, _PyLong_New returns the result of PyObject_NEW_VAR. I > >found PyObject_NEW_V

Re: How Python Implements "long integer"?

2009-07-05 Thread Pedram
On Jul 5, 8:32 pm, Pedram wrote: > On Jul 5, 8:12 pm, a...@pythoncraft.com (Aahz) wrote: > > > > > In article > > <6f6be2b9-49f4-4db0-9c21-52062d8ea...@l31g2000yqb.googlegroups.com>, > > > Pedram   wrote: > > > >This time I have a simple C question! > > >As you know, _PyLong_New returns the resul

Re: question of style

2009-07-05 Thread Lie Ryan
Steven D'Aprano wrote: > On Sun, 05 Jul 2009 11:37:49 +, Lie Ryan wrote: > >> Neither python's `if` nor `if` in formal logic is about testing True vs. >> False. `if` in python and formal logic receives a statement. The >> statement must be evaluatable to True or False, but does not have to be

Re: Determining if a function is a method of a class within a decorator

2009-07-05 Thread Piet van Oostrum
> David Hirschfield (DH) wrote: >DH> Yeah, it definitely seems like having two separate decorators is the >DH> solution. But the strange thing is that I found this snippet after some >DH> deep googling, that seems to do something *like* what I want, though I >DH> don't understand the descript

Re: Clarity vs. code reuse/generality

2009-07-05 Thread wwwayne
On Fri, 03 Jul 2009 14:34:58 GMT, Alan G Isaac wrote: >On 7/3/2009 10:05 AM kj apparently wrote: === 8< === >2. >from scipy.optimize import bisect >def _binary_search(lo, hi, func, target, epsilon): >def f(x): return func(x) - target >return bisect(f, lo, high, xtol=epsilon) > >3. If yo

A C++ user's introduction to Python: a really good read

2009-07-05 Thread Dotan Cohen
Here is a C++ KDE programer's take on Python: http://majewsky.wordpress.com/2009/07/04/python-experiences-or-why-i-like-c-more/ Good read. -- Dotan Cohen http://what-is-what.com http://gibberish.co.il -- http://mail.python.org/mailman/listinfo/python-list

Method to separate unit-test methods and data?

2009-07-05 Thread Nick Daly
Hi, I was wondering if it's possible / if there are any simple methods known of storing unit-test functions and their data in separate files? Perhaps this is a strange request, but it does an excellent job of modularizing code.  As far as revision control goes, it makes it easier to discern betwe

Creating alot of class instances?

2009-07-05 Thread kk
Hi I am new to Python classes and trying to figure out this particular issue here. I will need to create instances of a class. But at the moment I do not know how many instances I will end up having, in every case it might be different. Most of the documents I read makes this simpl class-student a

Re: question of style

2009-07-05 Thread Terry Reedy
Paul Rubin wrote: I don't know what a furphy is, but I don't accept that "somethingness" vs. "nothingness" is the same distinction as truth vs falsehood. True and False are values in a specific datatype (namely bool), not abstract qualities of arbitrary data structures. The idea that the "if"

Re: Creating alot of class instances?

2009-07-05 Thread Andre Engels
On 7/5/09, kk wrote: > I am new to Python classes and trying to figure out this particular > issue here. I will need to create instances of a class. But at the > moment I do not know how many instances I will end up having, in every > case it might be different. Most of the documents I read m

Re: Creating alot of class instances?

2009-07-05 Thread Tim Chase
The solution might be dead simple but I just cannot figure out at the moment. For example this is what I need in the simplest form class myclass(): def __init__(self,name): self.name=name for count,data in enumerate(some list): instance_count=myclass() instance_count.name=data print inst

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-05 Thread Martin v. Löwis
> This is a good test for Python implementation bottlenecks. Run > that tokenizer on HTML, and see where the time goes. I looked at it with cProfile, and the top function that comes up for a larger document (52k) is ...validator.HTMLConformanceChecker.__iter__. This method dispatches various val

Re: Creating alot of class instances?

2009-07-05 Thread kk
Hi Thank you soo much for speedy and in detailed help. Your replies really cleared out most of the cloud for me. I have one last issue to resolve which is something I did not articulate properly, I realize now. The last issue is actually automatically naming the instances. The reason I was using t

Re: XML(JSON?)-over-HTTP: How to define API?

2009-07-05 Thread vasudevram
On Jul 3, 1:11 pm, "Diez B. Roggisch" wrote: > Allen Fowler schrieb: > > > > > > > > >> I have an (in-development) python system that needs to shuttle events / > >> requests > >> around over the network to other parts of itself.   It will also need to > >> cooperate with a .net application runnin

Re: Creating alot of class instances?

2009-07-05 Thread Rickard Lindberg
> Thank you soo much for speedy and in detailed help. Your replies > really cleared out most of the cloud for me. I have one last issue to > resolve which is something I did not articulate properly, I realize > now. The last issue is actually automatically naming the instances. > The reason I was u

memoization module?

2009-07-05 Thread kj
Is there a memoization module for Python? I'm looking for something like Mark Jason Dominus' handy Memoize module for Perl. TIA! kj -- http://mail.python.org/mailman/listinfo/python-list

Re: memoization module?

2009-07-05 Thread Lino Mastrodomenico
2009/7/5 kj : > Is there a memoization module for Python?  I'm looking for something > like Mark Jason Dominus' handy Memoize module for Perl. Check out the "memoized" class example here: -- Lino Mastrodomenico -- http://mail.pytho

Re: Creating alot of class instances?

2009-07-05 Thread Tim Chase
For example lets say I have class MyMaterials: and my instances might need to look like material_01 material_02 or light_01 light_02 or Mesh_01 Mesh_02 etc If you do not know how many instances you are going to create from the beginning, there is no way for you to know which of the instances

Re: Creating alot of class instances?

2009-07-05 Thread Christian Heimes
kk wrote: > I will be querying some data and create class instances based on the > data I gather. But the problem as I mentioned is that I do not know > the names and the number of the end class instances. They will be > based on the content of the data. So how can I create class instances > within

Re: pep 8 constants

2009-07-05 Thread Rhodri James
On Fri, 03 Jul 2009 15:52:31 +0100, MRAB wrote: Eric S. Johansson wrote: Horace Blegg wrote: I've been kinda following this. I have a cousin who is permanently wheel chair bound and doesn't have perfect control of her hands, but still manages to use a computer and interact with society. H

Re: pep 8 constants

2009-07-05 Thread Tim Chase
You can get giant piano keyboards that you step on, so how about a giant computer keyboard? "I wrote 5 miles of code before lunch!" :-) You can get/make MIDI organ pedal-boards (a friend of mine has two). From there it's just one small step... Is that a two-step? a box-step? Count it off...

Re: PEP368 and pixeliterators

2009-07-05 Thread Rhodri James
On Fri, 03 Jul 2009 09:21:09 +0100, Steven D'Aprano wrote: On Thu, 02 Jul 2009 10:32:04 +0200, Joachim Strömbergson wrote: for pixel in rgb_image: # swap red and blue, and set green to 0 pixel.value = pixel.b, 0, pixel.r The idea I'm having is that fundamentally the image is made

Re: Wrapping comments

2009-07-05 Thread Michael Torrie
Lawrence D'Oliveiro wrote: > I tried using Emacs via SSH from a Mac once. Made me run screaming for the > nearest Windows box > . Interesting rant, but the problem is with the key bindings they chose to use in Terminal.

Re: question of style

2009-07-05 Thread Paul Rubin
Steven D'Aprano writes: > > but I don't accept that "somethingness" > > vs. "nothingness" is the same distinction as truth vs falsehood. > > It's the distinction used by Python since the dawn of time. Python only > grew a bool type a few versions back. That's true, part of the situation we have

Re: question of style

2009-07-05 Thread Paul Rubin
Simon Forman writes: > BTW, Paul, kind of a tangent: I reimplemented the same algorithm but > using tuples instead of instances (and empty tuples for "NULL" > values.) I was trying to mess around in the space you seemed to > indicate existed, i.e. a better implementation using other datatypes, >

Re: Wrapping comments

2009-07-05 Thread Lawrence D'Oliveiro
In message , Michael Torrie wrote: > Lawrence D'Oliveiro wrote: > >> I tried using Emacs via SSH from a Mac once. Made me run screaming for >> the nearest Windows box >> . > > Interesting rant, but the problem is with

Why is my code faster with append() in a loop than with a large list?

2009-07-05 Thread Xavier Ho
(Here's a short version of the long version below if you don't want to read:) Why is version B of the code faster than version A? (Only three lines different) Version A: http://pastebin.com/f14561243 Version B: http://pastebin.com/f1f657afc I was

Re: memoization module?

2009-07-05 Thread Daniel Fetchinson
> Is there a memoization module for Python? I'm looking for something > like Mark Jason Dominus' handy Memoize module for Perl. The Python Cookbook has several examples: http://www.google.com/search?q=python+memoize&sitesearch=code.activestate.com HTH, Daniel -- Psss, psss, put it down! -

Re: finding most common elements between thousands of multiple arrays.

2009-07-05 Thread Scott David Daniels
Scott David Daniels wrote: ... Here's a heuristic replacement for my previous frequency code: I've tried to mark where you could fudge numbers if the run time is at all close. Boy, I cannot let go. I did a bit of a test checking for cost to calculated number of discovered samples, and found af

Re: Why is my code faster with append() in a loop than with a large list?

2009-07-05 Thread David
Xavier Ho wrote: (Here's a short version of the long version below if you don't want to read:) Why is version B of the code faster than version A? (Only three lines different) Version A: http://pastebin.com/f14561243 Version B: http://pastebin.com/f1f657afc I don't know but here is the diff

Re: Why is my code faster with append() in a loop than with a large list?

2009-07-05 Thread MRAB
Xavier Ho wrote: (Here's a short version of the long version below if you don't want to read:) Why is version B of the code faster than version A? (Only three lines different) Version A: http://pastebin.com/f14561243 Version B: http://pastebin.com/f1f657afc -

Re: Python and webcam capture delay?

2009-07-05 Thread Tim Roberts
"jack catcher (nick)" wrote: > >I'm thinking of using Python for capturing and showing live webcam >stream simultaneously between two computers via local area network. >Operating system is Windows. I'm going to begin with VideoCapture >extension, no ideas about other implementation yet. Do you

Re: PEP 376

2009-07-05 Thread Lawrence D'Oliveiro
In message , Charles Yeomans wrote: > On the contrary, MD5 was intended to be a cryptographic hash function, > not a checksum. Just like MD4 and MD2 before it. They have long since been considered worthless, and now MD5 has joined them. -- http://mail.python.org/mailman/listinfo/python-list

Adding the Copy Property to a Simple Histogram

2009-07-05 Thread W. eWatson
The code below produces a text window 60hx20w with a scroll bar. The contents are something of a histogram of values from 0 to 255. If one tries to copy the contents, Windows doesn't allow it. What needs to be done to allow a copy and paste? def ShowHistogram(self): if not self.cur

Help with Sockets.

2009-07-05 Thread tanner barnes
I am writing a program and in one section there is going to be a lobby with (for testing purposes) about 4 people in it. in the lobby there are two txtctrl's the first for entering your message and the second for displaying the message you and the other people in the lobby type. i am trying to

Re: Creating alot of class instances?

2009-07-05 Thread kk
Hi Thank you so much for wonderful tips and suggestions. I also found a solution to dynamic naming of the instances(I think). It does not sound like a very secure method but since my application will be just processing data one way I think it might be alright. I will compare to the list and dicti

A Bug By Any Other Name ...

2009-07-05 Thread Lawrence D'Oliveiro
I wonder how many people have been tripped up by the fact that ++n and --n fail silently for numeric-valued n. -- http://mail.python.org/mailman/listinfo/python-list

Re: A Bug By Any Other Name ...

2009-07-05 Thread Chris Rebert
On Sun, Jul 5, 2009 at 7:32 PM, Lawrence D'Oliveiro wrote: > I wonder how many people have been tripped up by the fact that > >    ++n > > and > >    --n > > fail silently for numeric-valued n. Given that C-style for-loops are relatively infrequent in Python and are usually written using range() w

Re: Adding the Copy Property to a Simple Histogram

2009-07-05 Thread Simon Forman
On Jul 5, 9:48 pm, "W. eWatson" wrote: > The code below produces a text window 60hx20w with a scroll bar. The > contents are something of a histogram of values from 0 to 255. If one tries > to copy the contents, Windows doesn't allow it. What needs to be done to > allow a copy and paste? > >      

Re: A Bug By Any Other Name ...

2009-07-05 Thread Steven D'Aprano
On Mon, 06 Jul 2009 14:32:46 +1200, Lawrence D'Oliveiro wrote: > I wonder how many people have been tripped up by the fact that > > ++n > > and > > --n > > fail silently for numeric-valued n. What do you mean, "fail silently"? They do exactly what you should expect: >>> ++5 # posit

Re: finding most common elements between thousands of multiple arrays.

2009-07-05 Thread Steven D'Aprano
On Sun, 05 Jul 2009 17:30:58 -0700, Scott David Daniels wrote: > Summary: when dealing with numpy, (or any bulk <-> individual values > transitions), try several ways that you think are equivalent and > _measure_. This advice is *much* more general than numpy -- it applies to any optimization ex

Re: Adding the Copy Property to a Simple Histogram

2009-07-05 Thread W. eWatson
Simon Forman wrote: On Jul 5, 9:48 pm, "W. eWatson" wrote: The code below produces a text window 60hx20w with a scroll bar. The contents are something of a histogram of values from 0 to 255. If one tries to copy the contents, Windows doesn't allow it. What needs to be done to allow a copy and p

Re: Creating alot of class instances?

2009-07-05 Thread Steven D'Aprano
On Sun, 05 Jul 2009 19:27:25 -0700, kk wrote: > Hi > > Thank you so much for wonderful tips and suggestions. > > I also found a solution to dynamic naming of the instances(I think). It > does not sound like a very secure method but since my application will > be just processing data one way I th

Re: Clarity vs. code reuse/generality

2009-07-05 Thread David Smith
kj wrote: > In <7x4otsux7f@ruckus.brouhaha.com> Paul Rubin > writes: > >> kj writes: >>> sense = cmp(func(hi), func(lo)) >>> assert sense != 0, "func is not strictly monotonic in [lo, hi]" > >> bisection search usually just requires the function to be

Re: A Bug By Any Other Name ...

2009-07-05 Thread Gabriel Genellina
En Mon, 06 Jul 2009 00:28:43 -0300, Steven D'Aprano escribió: On Mon, 06 Jul 2009 14:32:46 +1200, Lawrence D'Oliveiro wrote: I wonder how many people have been tripped up by the fact that ++n and --n fail silently for numeric-valued n. What do you mean, "fail silently"? They do

Re: mail

2009-07-05 Thread Banibrata Dutta
On Sat, Jul 4, 2009 at 9:51 PM, wrote: > Hi, > > I want to know that whether using python programming is it possible to > extract chemical shift information about some amino acids of some protein > from BMRB(BioMagResBank) or Ref-DB(referenced databank) or not. > > Thanks, > Amrita Kumari > Resea

Re: Creating alot of class instances?

2009-07-05 Thread kk
Steven, Before your post I was contemplating about the merits of using the globals(). After reading your post I am totally convinced that your suggestion that was also suggested by previous posters is the way to go. At first I thought it would be limiting to not to have the instance names properly

Re: Does cProfile include IO wait time?

2009-07-05 Thread Gabriel Genellina
En Sat, 04 Jul 2009 21:03:38 -0300, Matthew Wilson escribió: I expected to see a bunch of my IO file-reading code in there, but I don't. So this makes me think that the profiler uses CPU time, not clock-on-the-wall time. I'm not an expert on python profiling, and the docs seem sparse. Can

Re: Help with Sockets.

2009-07-05 Thread Gabriel Genellina
En Sun, 05 Jul 2009 23:06:30 -0300, tanner barnes escribió: I am writing a program and in one section there is going to be a lobby with (for testing purposes) about 4 people in it. in the lobby there are two txtctrl's the first for entering your message and the second for displaying the

  1   2   >