#emc-devel | Logs for 2007-05-26

Back
[00:52:34] <jmkasunich> hi guys
[01:57:02] <jepler> hi jmkasunich
[01:57:30] <jmkasunich> hi
[01:57:45] <jmkasunich> this python stuff is rather amazing
[01:58:02] <jepler> no strange feature has bitten you in the ass yet?
[01:58:14] <jmkasunich> oh, I've been nibbled on a bit
[01:58:19] <jmkasunich> but no major chunks missing
[01:58:25] <jepler> good
[01:58:55] <jepler> how close are you to your goals?
[01:59:11] <jmkasunich> If I pastebin what I've got so far, would you mind taking a look at it? I want to make sure I'm not doing anything boneheaded
[01:59:48] <jepler> sure, but I'm actually at a friend's and probably shouldn't chat too long
[02:00:13] <jmkasunich> this can wait
[02:00:51] <jmkasunich> I'm finishing up some error checking/validation code, then I'm gonna move on to "its parsed, now do something usefull with it"
[02:01:31] <jmkasunich> I had a bit of a setback - about a 4 hour power failure here (storm)
[02:01:39] <jmkasunich> only got booted back up recently
[02:01:52] <jepler> oh really
[02:02:46] <jmkasunich> 15 minute UPS doesn't do much good when the power goes out at 4ish, and I'm at work till 5:30 ;-(
[02:15:39] <petev> cradek, u there?
[03:18:57] <cradek> not really
[03:19:06] <cradek> (not for long)
[03:31:52] <petev> what do you think about making fengli a developer?
[03:32:04] <petev> I took a look at his Qt GUI, and it's not bad
[03:32:11] <petev> I think he's off to an ok start
[03:32:47] <petev> the GUI code should be pretty well isolated, so I don't think he would really do any harm
[15:40:50] <jmkasunich> jepler: you around?
[15:43:22] <jepler> jmkasunich: yeah
[15:43:45] <jmkasunich> I don't see any mention of arrays in the tutorial, although google does say py has arrays
[15:43:56] <jmkasunich> can I make an array of lists?
[15:44:26] <jepler> the elements of lists can be lists
[15:44:26] <jmkasunich> I know I could make a dict with integers as keys, and pretend its an array, but that seems strange
[15:44:47] <jepler> if you want to index by numbers, then you want a list
[15:45:27] <jepler> (unless you have a special purpose in mind, like storing an array of 'char' or 'long' in the same way that C would, for binary I/O of some sort)
[15:46:10] <jmkasunich> what I'm doing: I have a bunch of instances (in a dict of class objects, but it could be a list of objs or whatever)
[15:46:20] <jmkasunich> each has a "num_addr_bits" member
[15:46:53] <jmkasunich> I want to build an array of lists, from a[0] to a[14], which contains the objects having that number of bits
[15:47:12] <jepler> why do you know that the biggest index is 14?
[15:47:15] <jmkasunich> sort of a histogram - loop thru the instances, assigning each one to a bin
[15:47:31] <jmkasunich> because if its bigger it won't fit in the address space of the FPGA
[15:47:38] <jepler> ok
[15:47:46] <jmkasunich> there may be a bigger number in the source file, but if so its an error and I want to report it
[15:48:24] <jepler> instances_by_bits = [ [] for i in range(15) ] # Make a list of 15 empty lists
[15:48:55] <jepler> then you can put the instances into the bins with a loop like this one:
[15:48:55] <jepler> for i in instances:
[15:48:55] <jepler> instances_by_bits[i.num_addr_bits].append(i)
[15:49:39] <jmkasunich> I just had a duh moment... I didn't realize that lists can be accessed using subscripts
[15:50:06] <jepler> oh!
[15:50:30] <jmkasunich> I think I overlooked that page, and was assuming things like append, insert, remove, index, were the only way
[15:52:00] <jepler> is this notation something I should explain further: instances_by_bits = [ [] for i in range(15) ]
[15:52:11] <jmkasunich> I think I get it
[15:52:22] <jmkasunich> [] makes an empty list (I've used that already)
[15:52:22] <jepler> OK
[15:52:58] <jmkasunich> for i in range(15) iterates i from 0 to 14
[15:53:11] <jmkasunich> the contatenation of the two is new
[15:53:48] <jmkasunich> I really hate error checking
[15:54:28] <jmkasunich> my code has gotten rather crufted up, because I
[15:55:07] <jmkasunich> because I'm trying to give the user helpfull info instead of stack tracebacks for at least common errors in the input file
[15:55:42] <jmkasunich> I think I've restructured the parsing code three times
[15:55:48] <jepler> yeah it's a hard trade-off
[15:56:35] <jmkasunich> first pass: parse all instance requests from the source file, parse all module specs from the "library", then make sure a spec exists for every type of instance requested
[15:56:42] <jmkasunich> first version I mean
[15:57:12] <jmkasunich> 2nd version: parse all instance requests, then parse a module spec for each type of instance requested (don't parse it if you don;t need it)
[15:58:00] <jmkasunich> 3rd version: like the 2nd, but put "look for (and parse if not found) a matching module spec" in the instance class __init__
[15:58:36] <jmkasunich> each time I thought I was making it better, but now I'm not so sure
[16:00:36] <jepler> stop changing it then, and see if using the tool gives you a better understanding of the trade-offs
[16:00:43] <jmkasunich> heh
[16:01:30] <jmkasunich> thats kind of the conclusion I reached... but I'm less worried about ME needing the messages than I am about other people needing them
[16:02:31] <jmkasunich> anyway, I moved on to the address decode stuff, hence the array question
[16:07:17] <jmkasunich> hmm.... "for i in instances : " results in i being the key, not the instance object
[16:07:38] <jmkasunich> (instances is a dict of name:object pairs)
[16:08:17] <jmkasunich> I can do for name, i in instances.iteritems() :
[16:08:29] <jmkasunich> I don't need name though - is there a way to get just the objects?
[16:16:53] <jepler> oh
[16:17:08] <jepler> there are .keys(), .values(), .items() as well as 'iter' variants
[16:17:57] <jmkasunich> thanks
[16:18:05] <jmkasunich> I knew about keys, didn't know about the others
[17:01:08] <jmkasunich> does python have the equivalent of "foo++", "foo *= 3", "foo <<= 2", etc? or do you write them out as "foo = foo + 1" ?
[17:01:40] <jepler> it does have 'foo *= 3' but not 'foo++'
[17:01:54] <jmkasunich> thanks
[17:03:36] <jmkasunich> I suppose I should have just tried it...
[17:04:03] <jepler> yeah
[17:04:30] <jmkasunich> still adapting to the interpreter way of doing things
[21:47:17] <a-l-p-h-a> jmkasunich, how's the mesa Step/dir stuff going?
[21:47:23] <a-l-p-h-a> anything I maybe able to help with?
[21:47:59] <jmkasunich> a-l-p-h-a: working on infrastructure stuff right now
[21:48:23] <a-l-p-h-a> cool.