Re: Enumerating k-segmentations of a sequence

2008-11-26 Thread bullockbefriending bard
On Nov 26, 12:15 am, [EMAIL PROTECTED] wrote: > bullockbefriending bard napisa³(a): > > > > > I'm not sure if my terminology is precise enough, but what I want to > > do is: > > > Given an ordered sequence of n items, enumerate all its possible k- > > se

Enumerating k-segmentations of a sequence

2008-11-25 Thread bullockbefriending bard
I'm not sure if my terminology is precise enough, but what I want to do is: Given an ordered sequence of n items, enumerate all its possible k- segmentations. This is *not* the same as enumerating the k set partitions of the n items because I am only interested in those set partitions which prese

Re: design choice: multi-threaded / asynchronous wxpython client?

2008-04-27 Thread bullockbefriending bard
On Apr 27, 11:27 pm, "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote: > I think twisted is overkill for this problem. Threading, elementtree > and urllib should more than suffice. One thread polling the server for > each race with the desired polling interval. Each time some data is > treated, that thr

Re: design choice: multi-threaded / asynchronous wxpython client?

2008-04-27 Thread bullockbefriending bard
On Apr 27, 11:12 pm, Jorge Godoy <[EMAIL PROTECTED]> wrote: > bullockbefriending bard wrote: > > A further complication is that at a later point, I will want to do > > real-time time series prediction on all this data (viz. predicting > > actual starting prices at post t

Re: design choice: multi-threaded / asynchronous wxpython client?

2008-04-27 Thread bullockbefriending bard
On Apr 27, 10:10 pm, David <[EMAIL PROTECTED]> wrote: > >  1) The data for the race about to start updates every (say) 15 > >  seconds, and the data for earlier and later races updates only every > >  (say) 5 minutes. There is  no point for me to be hammering the server > >  with requests every 15

Re: design choice: multi-threaded / asynchronous wxpython client?

2008-04-27 Thread bullockbefriending bard
On Apr 27, 10:05 pm, "Eric Wertman" <[EMAIL PROTECTED]> wrote: > HI, that does look like a lot of fun... You might consider breaking > that into 2 separate programs.  Write one that's threaded to keep a db > updated properly, and write a completely separate one to handle > displaying data from your

design choice: multi-threaded / asynchronous wxpython client?

2008-04-27 Thread bullockbefriending bard
I am a complete ignoramus and newbie when it comes to designing and coding networked clients (or servers for that matter). I have a copy of Goerzen (Foundations of Python Network Programming) and once pointed in the best direction should be able to follow my nose and get things sorted... but I am n

Re: Generator for k-permutations without repetition

2007-07-04 Thread bullockbefriending bard
On Jul 4, 7:09 pm, Nis Jørgensen <[EMAIL PROTECTED]> wrote: > bullockbefriending bard skrev: > > > > > I was able to google a recipe for a k_permutations generator, such > > that i can write: > > > x = range(1, 4) # (say) > > [combi for combi in k_p

Generator for k-permutations without repetition

2007-07-04 Thread bullockbefriending bard
I was able to google a recipe for a k_permutations generator, such that i can write: x = range(1, 4) # (say) [combi for combi in k_permutations(x, 3)] => [[1, 1, 1], [1, 1, 2], [1, 1, 3], [1, 2, 1], [1, 2, 2], [1, 2, 3], [1, 3, 1], [1, 3, 2], [1, 3, 3], [2, 1, 1], [2, 1, 2], [2, 1, 3], [2, 2, 1

Re: matching objects by a tuple field criterion

2007-06-10 Thread bullockbefriending bard
> There are certainly cases where the speedup is tremendous - think of a > single integer in the first criteria - but then the overall performance > depends on the real-live queries. If lot's of wildcards are used, you > might end up slower if the tree-walk takes more time than the > C-implemented

Re: matching objects by a tuple field criterion

2007-06-10 Thread bullockbefriending bard
quite so, i rephrased docstring to be: """criteria is an iterable containing either '*' instances or strings of comma-separated integers. e.g. ['*','1,2,3', '11,12']""" thanks very much for the idea! upon further reflection, this seems to be a more elegant solution for my case than the ad-hoc g

Re: matching objects by a tuple field criterion

2007-06-10 Thread bullockbefriending bard
> Instead of passing a wild-card tuple like (*,*,*,4,*,*) simply pass the > integer you want to match and the position you want to match it in. for sure. that was more for expository purpose rather than how i was planning to go about it. > As a generator expression: > > (obj for obj in list_of_

matching objects by a tuple field criterion

2007-06-10 Thread bullockbefriending bard
i have a large collection of python objects, each of which contains an integer 6-tuple as part of its data payload. what i need to be able to do is select only those objects which meet a simple tuple element wildcard matching criterion. e.g. given the following python objects: object A include

Re: speeding things up with C++

2007-06-01 Thread bullockbefriending bard
> Are you sure you want an STL container? Since the primary operator > here is Python, the extra benefits from the STL container over plain C > arrays isn't as evident. > > Pyrex is a good way to write the interface between your C++ code and > the Python code - it handles the refcounting and boile

Re: speeding things up with C++

2007-05-31 Thread bullockbefriending bard
suggest. On May 31, 3:04 am, Jorgen Grahn <[EMAIL PROTECTED]> wrote: > On 26 May 2007 02:19:39 -0700, bullockbefriending bard <[EMAIL PROTECTED]> > wrote: > ... > > > Essentially, I need to pass a list of 6-tuples containing only > > integers to my new sadly ne

Re: speeding things up with C++

2007-05-28 Thread bullockbefriending bard
thanks. i'll definitely look into this. On May 28, 10:48 pm, Kay Schluehr <[EMAIL PROTECTED]> wrote: > On May 26, 11:19 am, bullockbefriending bard <[EMAIL PROTECTED]> > wrote: > > > > > I've done all the requisite profiling and thought fairly deeply

Re: speeding things up with C++

2007-05-28 Thread bullockbefriending bard
I wonder if Jython might be the answer? Java is going to be faster than Python for the time-critical part of my program. Does anybody have experience getting data structures like nested lists / tuples into a java routine from a running jython program (and then back again)? -- http://mail.python.o

Re: speeding things up with C++

2007-05-28 Thread bullockbefriending bard
thanks! i'll look into this. On May 27, 5:35 am, Che Guevara <[EMAIL PROTECTED]> wrote: > On May 26, 11:19 am, bullockbefriending bard <[EMAIL PROTECTED]> > wrote: > > > However, I hope someone reading this will be able to tell me that I'm > > being

speeding things up with C++

2007-05-26 Thread bullockbefriending bard
I've done all the requisite profiling and thought fairly deeply about the efficiency of my python code, but am still going to have to speed up the innermost guts of what I am doing. Essentially, I need to pass a list of 6-tuples containing only integers to my new sadly necessary super-fast compile

Re: regex matching question

2007-05-19 Thread bullockbefriending bard
> > No way? Famous last words :-) > > C:\junk>type showargs.py > import sys; print sys.argv > > C:\junk>\python25\python > Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit > (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> import

Re: regex matching question

2007-05-19 Thread bullockbefriending bard
> Here "all pairs different" means "for each pair, both numbers must be > different", but they may appear in another pair. That is, won't flag > "1,2/3,4/3,5/2,6/8,3/1,2" as invalid, but this wasn't clear from your > original post. > > -- > Gabriel Genellina thanks! you are correct that the

Re: regex matching question

2007-05-19 Thread bullockbefriending bard
> Instead of the "or match.group(0) != results" caper, put \Z (*not* $) at > the end of your pattern: > mobj = re.match(r"pattern\Z", results) > if not mobj: as the string i am matching against is coming from a command line argument to a script, is there any reason why i cannot get away wi

Re: regex matching question

2007-05-19 Thread bullockbefriending bard
> Backslash? Your example uses a [forward] slash. correct.. my mistake. i use forward slashes. > Are you sure you don't want to allow for some spaces in the data, for > the benefit of the humans, e.g. > 1,2 / 3,4 / 5,6 / 7,8 / 9,10 / 11,12 you are correct. however, i am using string as a co

Re: regex matching question

2007-05-19 Thread bullockbefriending bard
L PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, > > > > bullockbefriending bard wrote: > > first, regex part: > > > I am new to regexes and have come up with the following expression: > > ((1[0-4]|[1-9]),(1[0-4]|[1-9])/){5}(1[0-4]|[1-9]),(1[0-4]|[1-9]) > > > to exa

regex matching question

2007-05-19 Thread bullockbefriending bard
first, regex part: I am new to regexes and have come up with the following expression: ((1[0-4]|[1-9]),(1[0-4]|[1-9])/){5}(1[0-4]|[1-9]),(1[0-4]|[1-9]) to exactly match strings which look like this: 1,2/3,4/5,6/7,8/9,10/11,12 i.e. 6 comma-delimited pairs of integer numbers separated b

Re: List comprehension returning subclassed list type?

2007-03-25 Thread bullockbefriending bard
57 pm, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sat, 24 Mar 2007 23:43:10 -0700, bullockbefriending bard wrote: > > z_list = [Z(y.var1, y.var2,..) for y in list_of_objects_of_class_Y] > > > Of course this just gives me a plain list and no access to the > > m

List comprehension returning subclassed list type?

2007-03-24 Thread bullockbefriending bard
Given: class Z(object): various defs, etc. class ZList(list): various defs, etc. i would like to be able to replace z_list = ZList() for y in list_of_objects_of_class_Y: z_list.append(y) with something like this: z_list = [Z(y.var1, y.var2,..) for y in list_of_objects_of_class_Y]

Re: 6 Pick Bet Grouping

2006-11-28 Thread bullockbefriending bard
Sorry, I perhaps didn't frame my initial post very well. I hope my reply to your other post below has answered these questions. -- http://mail.python.org/mailman/listinfo/python-list

Re: 6 Pick Bet Grouping

2006-11-28 Thread bullockbefriending bard
Your explanation is correct. It's important to realise that effectively the input many thousands of single bets come out of a black box and it is then necessary for me to merge them into the grouped format to make things more manageable. Given an arbitrary bucket of single bets, it is by no means o

6 Pick Bet Grouping

2006-11-28 Thread bullockbefriending bard
(I apologise in advance for posting something slightly OT, but plead in mitigation that I'm trying to re-write an old, suboptimal VB6 (erk) brute-force attack in a shiny, elegant, pythonic manner. I would really appreciate some ideas about an appropriate algorithmic approach to this + pointers to a