Re: GC is very expensive: am I doing something wrong?

2010-03-22 Thread Steven D'Aprano
On Mon, 22 Mar 2010 22:05:40 -0700, Paul Rubin wrote: > Antoine Pitrou writes: >> "Orders of magnitude worse", in any case, sounds very exaggerated. > > The worst case can lose orders of magnitude if a lot of values hash to > the same bucket. Well, perhaps one order of magnitude. >>> for i i

Re: Castrated traceback in sys.exc_info()

2010-03-22 Thread Gabriel Genellina
En Mon, 22 Mar 2010 15:20:39 -0300, Pascal Chambon escribió: Allright, here is more concretely the problem : ERROR:root:An error Traceback (most recent call last): File "C:/Users/Pakal/Desktop/aaa.py", line 7, in c return d() File "C:/Users/Pakal/Desktop/aaa.py", line 11, in d def

Re: GC is very expensive: am I doing something wrong?

2010-03-22 Thread Paul Rubin
Antoine Pitrou writes: > "Orders of magnitude worse", in any case, sounds very exaggerated. The worst case can lose orders of magnitude if a lot of values hash to the same bucket. -- http://mail.python.org/mailman/listinfo/python-list

Re: device identification

2010-03-22 Thread Tim Roberts
Omer Ihsan wrote: > >i have installed pyusb now and run the sample usbenum.pyi have 3 >usb ports on my PC but the results show 6 outputs to >dev.filename..they are numbers like 001 or 005 etc and they >changed when i plugged in devices...(i am no good with the usb >standards)i just wan

Re: google token

2010-03-22 Thread Rami Chowdhury
On Monday 22 March 2010 17:23:27 Thufir wrote: > On Mar 20, 3:12 am, Steven D'Aprano > cybersource.com.au> wrote: > > On Sat, 20 Mar 2010 09:17:14 +, Thufir wrote: > > > I'd like to acquire a token, as below, but from Java: > > Perhaps you should be asking a Java discussion group? This group

Re: short-circuiting any/all ?

2010-03-22 Thread kj
In Steven D'Aprano writes: >On Mon, 22 Mar 2010 22:19:57 +, kj wrote: >In any case, the once-off cost of creating or importing a function is >usually quite cheap. As usual, the best advise is not to worry about >optimization until you have profiled the code and learned where the >actual

Re: GC is very expensive: am I doing something wrong?

2010-03-22 Thread Antoine Pitrou
Le Mon, 22 Mar 2010 23:40:16 +, tan a écrit : > >>Remember that the original use case was to load a dictionary from a text >>file. For this use case, a trie can be very wasteful in terms of memory >>and rather CPU cache unfriendly on traversal, whereas hash values are a) >>rather fast to calcu

Re: short-circuiting any/all ?

2010-03-22 Thread Steven D'Aprano
On Mon, 22 Mar 2010 22:19:57 +, kj wrote: > In Tim Golden > writes: > >>On 22/03/2010 18:30, kj wrote: >>> Thanks! I'm glad to know that one can get the short circuiting using >>> a map-type idiom. (I prefer map over comprehensions when I don't need >>> to define a function just for the p

Re: individually updating unicodedata db?

2010-03-22 Thread MRAB
Vlastimil Brom wrote: Hi all, I just tried to find some information about the unicodedata database and the possibilities of updating it to the latest version of the unicode standards (currently 5.2, while python supports 5.1 in the latest versions). An option to update this database individually

Re: google token

2010-03-22 Thread Thufir
On Mar 20, 3:12 am, Steven D'Aprano wrote: > On Sat, 20 Mar 2010 09:17:14 +, Thufir wrote: > > I'd like to acquire a token, as below, but from Java: > > Perhaps you should be asking a Java discussion group? This group is for > discussing Python. > > -- > Steven What I meant to ask is, how is

individually updating unicodedata db?

2010-03-22 Thread Vlastimil Brom
Hi all, I just tried to find some information about the unicodedata database and the possibilities of updating it to the latest version of the unicode standards (currently 5.2, while python supports 5.1 in the latest versions). An option to update this database individually might be useful as the u

Re: GC is very expensive: am I doing something wrong?

2010-03-22 Thread tan
In article , Stefan Behnel wrote: >Lawrence D'Oliveiro, 22.03.2010 00:36: >> Terry Reedy wrote: >>> No one has discovered a setting >>> of the internal tuning parameters for which there are no bad patterns >>> and I suspect there are not any such. This does not negate Xavier's >>> suggestion that

Re: DreamPie - The Python shell you've always dreamed about!

2010-03-22 Thread Steve Holden
Luis M. González wrote: > On Feb 21, 6:40 pm, Mensanator wrote: >> On Feb 21, 12:14 pm, Paul Boddie wrote: >> >> >> >> >> >>> On 21 Feb, 17:32, Mensanator wrote: On Feb 21, 10:30 am, Mensanator wrote: > What versions of Python does it suuport? What OS are supported? >>> From the W

Re: short-circuiting any/all ?

2010-03-22 Thread kj
In Tim Golden writes: >On 22/03/2010 18:30, kj wrote: >> Thanks! I'm glad to know that one can get the short circuiting >> using a map-type idiom. (I prefer map over comprehensions when I >> don't need to define a function just for the purpose of passing it >> to it.) >In what way does "map"

Re: How to automate accessor definition?

2010-03-22 Thread kj
In <4ba79040$0$22397$426a7...@news.free.fr> Bruno Desthuilliers writes: >kj a écrit : >> PS: BTW, this is not the first time that attempting to set an >> attribute (in a class written by me even) blows up on me. It's >> situations like these that rattle my grasp of attributes, hence my >> origi

Re: StringChain -- a data structure for managing large sequences of chunks of bytes

2010-03-22 Thread Zooko O'Whielacronx
On Mon, Mar 22, 2010 at 2:07 AM, Steven D'Aprano wrote: > > Perhaps you should have said that it was a wrapper around deque giving > richer functionality, rather than giving the impression that it was a > brand new data structure invented by you. People are naturally going to > be more skeptical a

Problem with sys.path when embedding Python3 in C

2010-03-22 Thread Krister Svanlund
Hi, I've recently begun experimenting with embedding python and i got a small problem. This is my current testing code (basically all from python docs): > int main(int argc, char *argv[]) > > { > > PyObject *pModuleName, *pTestModule, *pTestFunc, *pTestResult, *pTestArgs; > > PyImport_AppendInitta

Re: Castrated traceback in sys.exc_info()

2010-03-22 Thread Pascal Chambon
Gabriel Genellina a écrit : En Wed, 17 Mar 2010 09:42:06 -0300, Pascal Chambon escribió: traceback functions indeed allow the manipulation of exception tracebacks, but the root problem is that anyway, since that traceback is incomplete, your "traceback.format_exc().splitlines()" will only

Re: short-circuiting any/all ?

2010-03-22 Thread Tim Golden
On 22/03/2010 18:30, kj wrote: Thanks! I'm glad to know that one can get the short circuiting using a map-type idiom. (I prefer map over comprehensions when I don't need to define a function just for the purpose of passing it to it.) In what way does "map" over "comprehensions" save you defin

Re: short-circuiting any/all ?

2010-03-22 Thread kj
In <291d82b7-b13b-4f49-901c-8194f3e07...@e7g2000yqf.googlegroups.com> nn writes: >If you are in Python 3 "any(map(is_invalid, L))" should short circuit. >If you are in Python 2 use "from itertools import imap; >any(imap(is_invalid, L))" Thanks! I'm glad to know that one can get the short circu

Re: short-circuiting any/all ?

2010-03-22 Thread Raymond Hettinger
On Mar 22, 7:45 am, kj wrote: > I have a list of items L, and a test function is_invalid that checks > the validity of each item.  To check that there are no invalid > items in L, I could check the value of any(map(is_invalid, L)). > But this approach is suboptimal in the sense that, no matter wha

Re: DreamPie - The Python shell you've always dreamed about!

2010-03-22 Thread Luis M . González
On Feb 21, 6:40 pm, Mensanator wrote: > On Feb 21, 12:14 pm, Paul Boddie wrote: > > > > > > > On 21 Feb, 17:32, Mensanator wrote: > > > > On Feb 21, 10:30 am, Mensanator wrote: > > > > > What versions of Python does it suuport? > > > > What OS are supported? > > > From the Web site referenced i

Re: How to automate accessor definition?

2010-03-22 Thread John Posner
On 3/22/2010 11:44 AM, Bruno Desthuilliers wrote: Another (better IMHO) solution is to use a plain property, and store the computed value as an implementation attribute : @property def foo(self): cached = self.__dict__.get('_foo_cache') if cached is None: self._foo_cache = cached = self._some

Re: How to automate accessor definition?

2010-03-22 Thread Bruno Desthuilliers
kj a écrit : In Dennis Lee Bieber writes: On Sun, 21 Mar 2010 16:57:40 + (UTC), kj declaimed the following in gmane.comp.python.general: Regarding properties, is there a built-in way to memoize them? For example, suppose that the value of a property is obtained by parsing the content

Re: nonuniform sampling with replacement

2010-03-22 Thread Robert Kern
On 2010-03-21 05:11 AM, Jah_Alarm wrote: I've got a vector length n of integers (some of them are repeating), I recommend reducing it down to unique integers first. and I got a selection probability vector of the same length. How will I sample with replacement k (<=n) values with the probabil

Re: short-circuiting any/all ?

2010-03-22 Thread nn
kj wrote: > I have a list of items L, and a test function is_invalid that checks > the validity of each item. To check that there are no invalid > items in L, I could check the value of any(map(is_invalid, L)). > But this approach is suboptimal in the sense that, no matter what > L is, is_invali

Re: short-circuiting any/all ?

2010-03-22 Thread Tim Wintle
On Mon, 2010-03-22 at 14:45 +, kj wrote: > I have a list of items L, and a test function is_invalid that checks > the validity of each item. To check that there are no invalid > items in L, I could check the value of any(map(is_invalid, L)). > But this approach is suboptimal in the sense that,

Re: short-circuiting any/all ?

2010-03-22 Thread Jean-Michel Pichavant
kj wrote: I have a list of items L, and a test function is_invalid that checks the validity of each item. To check that there are no invalid items in L, I could check the value of any(map(is_invalid, L)). But this approach is suboptimal in the sense that, no matter what L is, is_invalid will be

Re: short-circuiting any/all ?

2010-03-22 Thread Tim Golden
On 22/03/2010 14:45, kj wrote: I have a list of items L, and a test function is_invalid that checks the validity of each item. To check that there are no invalid items in L, I could check the value of any(map(is_invalid, L)). But this approach is suboptimal in the sense that, no matter what L is

Re: add an entry to twentyquestions.org (please)

2010-03-22 Thread John Bokma
Ben Finney writes: > twenty questions writes: > >> add an entry to http:// > > Don't spam groups with your off-topic begging for a closed database silo > (please) Don't repeat spam -- John Bokma j3b Hacking & Hiking in Mexico - h

short-circuiting any/all ?

2010-03-22 Thread kj
I have a list of items L, and a test function is_invalid that checks the validity of each item. To check that there are no invalid items in L, I could check the value of any(map(is_invalid, L)). But this approach is suboptimal in the sense that, no matter what L is, is_invalid will be executed

Re: How to automate accessor definition?

2010-03-22 Thread Alf P. Steinbach
* kj: In Dennis Lee Bieber writes: On Sun, 21 Mar 2010 16:57:40 + (UTC), kj declaimed the following in gmane.comp.python.general: Regarding properties, is there a built-in way to memoize them? For example, suppose that the value of a property is obtained by parsing the contents of a

Re: How to automate accessor definition?

2010-03-22 Thread kj
In Dennis Lee Bieber writes: >On Sun, 21 Mar 2010 16:57:40 + (UTC), kj >declaimed the following in gmane.comp.python.general: >> Regarding properties, is there a built-in way to memoize them? For >> example, suppose that the value of a property is obtained by parsing >> the contents of a

Re: chroot fails with mount point passed to subprocess.Popen?

2010-03-22 Thread Alf P. Steinbach
* newton10471: Hi, I'm trying to use subprocess.Popen() to do a Linux chroot to a mount point passed in as a parameter to the following function: def getInstalledKernelVersion(mountPoint): linuxFsRoot = mountPoint + "/root" print "type of linuxFsRoot is %s" % type(linuxFsRoot) insta

Re: subtraction is giving me a syntax error

2010-03-22 Thread Albert van der Horst
In article <56597268-3472-4fd9-a829-6d9cf51cf...@e7g2000yqf.googlegroups.com>, Joel Pendery wrote: >So I am trying to write a bit of code and a simple numerical >subtraction > >y_diff = y_diff-H > >is giving me the error > >Syntaxerror: Non-ASCII character '\x96' in file on line 70, but no >encod

chroot fails with mount point passed to subprocess.Popen?

2010-03-22 Thread newton10471
Hi, I'm trying to use subprocess.Popen() to do a Linux chroot to a mount point passed in as a parameter to the following function: def getInstalledKernelVersion(mountPoint): linuxFsRoot = mountPoint + "/root" print "type of linuxFsRoot is %s" % type(linuxFsRoot) installedKernelVersion

Re: What is pkg-config for ?

2010-03-22 Thread Lawrence D'Oliveiro
In message , Gabriel Genellina wrote: > I fail to see how is this relevant to Python... Well, so many of the questions in this noisegroup seem to be about Windows problems, not Python ones... :) -- http://mail.python.org/mailman/listinfo/python-list

Re: accessing variable of the __main__ module

2010-03-22 Thread Jean-Michel Pichavant
News123 wrote: Hi, I wondered about the best way, that a module's function could determine the existance and value of variables in the __main__ module. What I came up with is: ### main.py ## import mod A = 4 if __name__ == "__main__": mod.f() ### mod.py ## def

Re: Tuples vs. variable-length argument lists

2010-03-22 Thread Jean-Michel Pichavant
Spencer Pearson wrote: Hi! This might be more of a personal-preference question than anything, but here goes: when is it appropriate for a function to take a list or tuple as input, and when should it allow a varying number of arguments? It seems as though the two are always interchangeable. For

Re: execute bash builtins in python

2010-03-22 Thread alex goretoy
actually using the -i param in the command to subprocess doesn't seem to work as well as setting PS1 to some garbage, it starts a new interactive shell therein kicking me out of python. :/ Thank you, -Alex Goretoy -- http://mail.python.org/mailman/listinfo/python-list

Re: StringChain -- a data structure for managing large sequences of chunks of bytes

2010-03-22 Thread Steven D'Aprano
On Sun, 21 Mar 2010 23:09:46 -0600, Zooko O'Whielacronx wrote: > But the use case that I am talking about is where you need to accumulate > new incoming strings into your buffer while alternately processing > leading prefixes of the buffer. [...] > Below are the abbreviated results of the benchmar

Re: execute bash builtins in python

2010-03-22 Thread alex goretoy
for the broken pipe error, perhaps theres a different way I can get shell output other than using subprocess? I need the output of alias command into a string and output of declare command into a string as well, I would like to also avoid creating of a single liner script to make this happen if at

Re: GC is very expensive: am I doing something wrong?

2010-03-22 Thread Stefan Behnel
Lawrence D'Oliveiro, 22.03.2010 00:36: Terry Reedy wrote: No one has discovered a setting of the internal tuning parameters for which there are no bad patterns and I suspect there are not any such. This does not negate Xavier's suggestion that a code change might also solve your problem. Could

Re: execute bash builtins in python

2010-03-22 Thread alex goretoy
I do have a problem however that I don't know how to solve. My application dies abruptly at random times because of this and I get this output error in the terminal: bash: line 0: declare: write error: Broken pipe and sometimes it crashes and I get this output error; this one maybe gtk related, y

Re: nonuniform sampling with replacement

2010-03-22 Thread Aram Ter-Sarkissov
On 22 мар, 01:27, Peter Otten <__pete...@web.de> wrote: > Jah_Alarm wrote: > > I've got a vector length n of integers (some of them are repeating), > > and I got a selection probability vector of the same length. How will > > I sample with replacement k (<=n) values with the probabilty vector. > >

Re: nonuniform sampling with replacement

2010-03-22 Thread Aram Ter-Sarkissov
On 22 мар, 01:28, "Alf P. Steinbach" wrote: > * Alf P. Steinbach: > > > > > * Jah_Alarm: > >> I've got a vector length n of integers (some of them are repeating), > >> and I got a selection probability vector of the same length. How will > >> I sample with replacement k (<=n) values with the proba