|
I think I figured out the multiprocessing bit, although I had to move some methods around to global instead of instance. The part I'm stuck on now before I get it working on windows is drawing triangles to an RGB image array, hopefully faster than cairo does it. Since I'm doing most of the work with numpy arrays I figure it wouldn't be too much more to try and throw my own rasterizing code in there and compare it to cairo. I know that if you assign to rectangular chunks of a 2d numpy array you end up saving a lot of time versus assigning to individual elements or using a lambda. Lets say I wanted to make a function called draw_triangle which takes as parameters a source image to draw on, 3 point coordinates and 4 colour coordinates. How would I go about doing this, if I'm looking to maximize performance? I'm thinking there has to be some well researched algorithms that chop up a triangle into optimal rectangular chunks for fast assignment, can anyone help me out? Is there a library which does this already (in windows as well as linux?)?
|
# ? Jan 13, 2009 21:48 |
|
|
# ? May 9, 2024 17:53 |
|
I'm taking a mathematics/computer science class that is basically a rushed introduction to python. The teacher spent all of lecture and lab trying to teach the class a crash course in unix environments all the while showing how his linux laptop is superior in performance to people's random xp installs. .. I just want to learn python dude Before anyone replies I'm totally comfortable with your average idiot "navigate around, sftp your homework to the teacher, use vim/pico/etc" he's teaching, its just a waste of time I think.
|
# ? Jan 14, 2009 02:02 |
|
Are you asking how to bang him? . . . If not, do you have a question?
|
# ? Jan 14, 2009 02:12 |
Not an Anthem posted:1) Type your teacher's name. 2) Hold shift. 3) Press the one key. 4)
|
|
# ? Jan 14, 2009 02:27 |
|
code:
tile: code:
code:
code:
|
# ? Jan 15, 2009 02:30 |
|
that's because type, et al, are class variables not instance variables. Also, help(str.split). e: et all? Am I retarded? Lonely Wolf fucked around with this message at 02:47 on Jan 15, 2009 |
# ? Jan 15, 2009 02:34 |
|
Lord Uffenham posted:that's because type et all are class variables not instance variables How would I fix that? Sorry, this is my second (third?) day actually using/learning Python so I don't know that much. Lord Uffenham posted:help(str.split) Aha! I knew there had to be something simpler for what I was doing. Thanks.
|
# ? Jan 15, 2009 02:42 |
|
You need to set them in the body of init not the class body.
|
# ? Jan 15, 2009 02:47 |
|
Lord Uffenham posted:You need to set them in the body of init not the class body. Aha! That got it to work. Thank you so much. [edit] How do I get a subclass to also call the parent's init? code:
scanlonman fucked around with this message at 02:56 on Jan 15, 2009 |
# ? Jan 15, 2009 02:51 |
|
scanlonman posted:The Tile class doesn't inherit the name, style, x, y, etc. of the Atom class. Is there something I can do so it gets from that too? Yes, you'll want to use super(): code:
TOO SCSI FOR MY CAT fucked around with this message at 04:56 on Jan 15, 2009 |
# ? Jan 15, 2009 03:30 |
|
scanlonman posted:Aha! That got it to work. Thank you so much. super(parent_class, self).__init__()
|
# ? Jan 15, 2009 03:35 |
|
If anyone wants to fool around with that picture triangle thing I was struggling with earlier I have an exe packaged for windows that seems to work on my computer just fine. The code is still a mess but it was a learning experience at least. You can grab it here if you want. All the parameters are in a config file called 'configulation', edit that and away you go. I'm going to try rewriting it now so that opengl does most of the heavy lifting.
|
# ? Jan 15, 2009 16:47 |
|
I get an error using super, I don't know why.code:
|
# ? Jan 15, 2009 22:43 |
|
scanlonman posted:I get an error using super, I don't know why. You've encountered one of the annoying gotchas in Python 2, the separation between old- and new-style classes. You must have your classes inherit from "object", or many features will break. Try code like this: code:
|
# ? Jan 15, 2009 22:55 |
|
Ahhh, thanks! My game is running so much better it's fun to see how fast things are going and how well it's working. I'm really liking Python.
|
# ? Jan 16, 2009 01:34 |
|
thou shalt not prematurely optimize: http://bugs.python.org/issue5000
|
# ? Jan 19, 2009 17:59 |
|
m0nk3yz posted:thou shalt not prematurely optimize: http://bugs.python.org/issue5000 Heh, I just had some fun optimizing something myself: http://lazypython.blogspot.com/2009/01/optimizing-view.html
|
# ? Jan 19, 2009 22:43 |
|
king_kilr posted:Heh, I just had some fun optimizing something myself: http://lazypython.blogspot.com/2009/01/optimizing-view.html Heh, I closed like, 4 or 5 multiprocessing bugs this weekend - then I searched and found like 7 more unassigned :\
|
# ? Jan 19, 2009 23:42 |
|
I'm trying to write some function to upload files via FTP. My "problem" is that it feels like I'm kludging my status updates with percent done, KB's uploaded, and KB per second. The reason I've done it as I've done it is that I can't think of a better way to pass data back and forth between each time the callback is called. In short, I hate screwing with global variables like this, is there a better way? code:
|
# ? Jan 20, 2009 19:21 |
|
I am trying to refactor the triangle approximator I posted previously in this thread. It was using cairo to draw alpha blended triangles onto a canvas, and using numpy to read this canvas as an array and calculate the root mean square error between this array and an array made from the source image. When I profiled the program, equal amounts of time were spent by cairo's fill method and by numpy's concatenate method (which I assume is called several times throughout the course of my RMSE scoring function.) Because the source images are 8-bit unsigned integer arrays they must be upscaled to 64-bit float arrays before they can be stacked, diff'd, squared and summed up, so numpy is doing a shitload of unneccesary work which adds up quickly. Cairo is also profoundly slow, taking a significant amount of time to draw what amounts to 100 triangles on a 640x480 canvas. Both of these things are responsible for hogging all the CPU time and making this program slow as poo poo, so I want to fix them. Rather than using cairo for drawing and numpy for calculating the root mean square error between two image buffers, my plan is to use the pyOpenGl bindings to do the drawing on hardware, and something else(?) to calculate the root mean square error, ditching numpy entirely if possible. I've never used openGL before, but looking at PyOpenGL's function reference, it appears that it supports drawing to frame buffer objects and compiling shaders. Can anyone give me any pointers as to what I have to do if I want to duplicate the functionality of my scoring function on the GPU? Here it is: code:
|
# ? Jan 20, 2009 23:44 |
|
I have a simple question about Parent/Child communication in wxpython in this paste: http://paste.pocoo.org/show/100865/ Also, related to the paste, I've been told that I shouldn't create another class under the function for the button to create the child frame. So, in other words, I should just create the class outside of the function and just using the function to instanciate the class? dorkface fucked around with this message at 05:14 on Jan 23, 2009 |
# ? Jan 23, 2009 05:11 |
|
Anyone familiar with PAMIE (http://pamie.sourceforge.net/)? I'm running PAMIE 2.0 on Python 2.5 and having problems accessing a nested frame (which it says it supports in the module as frame1.frame2.frame3). The frames on the page are laid out like this: |-name="nav" | |-name="content" |---name="DirectoryContents" |---name="DirectoryStructure" so I've got something similar to this (already assuming I've navigated to the website with the frame layout above): code:
code:
ekalb fucked around with this message at 06:59 on Jan 24, 2009 |
# ? Jan 24, 2009 05:43 |
|
So I'm still pretty new to python, but this confuses me. If i do something like:code:
code:
one: why doesn't the class of amat get changed? Is there something simple I am missing?
|
# ? Jan 24, 2009 17:09 |
|
numpy.matrix has a __new__ method that customizes how instances are actually created. It looks like it checks the argument that's passed to it and if it's a matrix (or a subclass), it instantiates another matrix and returns that instead. All that aside, what are you actually trying to do? If you're just trying to instantiate your subclass, do it directly: code:
|
# ? Jan 24, 2009 20:03 |
|
Anyone worked with validating XML parsers, or any form of XML validation? Python's always been weak in this area and most of the (half-hearted) attempts have faded and gone away over the last few years.
|
# ? Jan 27, 2009 16:26 |
|
lxml does validation
|
# ? Jan 27, 2009 17:47 |
|
I was inspired by the vocab-flashcard script posted earlier, and I want to make an English : German, German : English flashcard script. I can't decide on the best way to store the vocab words that I add. I was thinking about 3 dicts, one for nouns, verbs, and adjectives, but if I stored the words as {English:German} then I wouldn't be able to do a key lookup by value (German : English), even though the values would be as unique as the keys. So is a list of 2-tuples the better way to go, to preserve reversibility?
|
# ? Jan 27, 2009 17:54 |
|
Kire posted:I was inspired by the vocab-flashcard script posted earlier, and I want to make an English : German, German : English flashcard script. I can't decide on the best way to store the vocab words that I add. I was thinking about 3 dicts, one for nouns, verbs, and adjectives, but if I stored the words as {English:German} then I wouldn't be able to do a key lookup by value (German : English), even though the values would be as unique as the keys. No. Use one dict for English-German, and another for German-English. Whether you want to use multiple pairs of dicts for different pairs of speech is up to you.
|
# ? Jan 27, 2009 20:43 |
|
I'm using the sqlite3.Row row_factory and I've found that if I do a SQL join and have identically named columns in the join, the resulting row objects look like a dict with two of the same key. The value returned for row['key'] is the one for the first instance of the key. Am I missing something obvious? This seems like a pretty big oversight. I've formatted my query to request everything as table.column, I would've figured that the result would return the keys in table.column format.
|
# ? Jan 28, 2009 20:27 |
|
I'm making progress, thanks for the tip. Python is much easier to study when I have specific goal in mind that I want to work toward, instead of undirected "I just wanna learn about programming..." I'm having trouble incorporating Ä Ö Ü ß ä ö ü. IDLE prompted me to put this line at the top of my file when I tried to save: code:
code:
Kire fucked around with this message at 21:45 on Jan 28, 2009 |
# ? Jan 28, 2009 20:41 |
|
Try # -*- coding: utf8 -*- , then make sure IDLE is saving in UTF-8.
|
# ? Jan 28, 2009 22:46 |
|
I'm sorry for asking probably previously-answered questions that no one likes to reanswer again... but: (1) If I'm starting with Python, should I jump into 3.0 or 2.6? How common is it to not be able to find a 3.0 library for a common task that exists for 2.6? (2) What development environments are recommended? Are different IDEs generally used for console applications vs windows applications vs django?
|
# ? Jan 28, 2009 23:26 |
|
supster posted:I'm sorry for asking probably previously-answered questions that no one likes to reanswer again... but: 2.6. 3.0 is extremely new and almost nothing has been ported to it yet. 2.6 will include some of the newer libraries/ideas present in 3.0, so you'll be better off for learning 3.0 than someone who's used to older verisons of Python. 3.0 will not be mainstream for at least a year or two (someone like m0nk3yz or king_kilr will have a better estimate, probably). quote:(2) What development environments are recommended? Are different IDEs generally used for console applications vs windows applications vs django? This is totally up to you; many Pythonistas don't even use an IDE in the literal sense of the term (a big all inclusive whizbang thing with a built in browser and terminal and etc). Definitely don't think you'd need different editors for different "types" of Python coding, at any rate. Pick one and use that. I love vim (others emacs); others love TextMate (and it is quite good); some like IDLE or Eclipse-plus-some-Python-plugin; etc.
|
# ? Jan 29, 2009 02:45 |
|
supster posted:I'm sorry for asking probably previously-answered questions that no one likes to reanswer again... but: 1) 2.6 for all the reasons bitprophet said. 2) I really like Eclipse and PyDev. Outside of that I just use IDLE/vim/textpad/notepad. (For the record, I loathe Eclipse for C/C++/Java -- for some reason I just love it for Python, go figure.)
|
# ? Jan 29, 2009 03:01 |
|
bitprophet posted:2.6. 3.0 is extremely new and almost nothing has been ported to it yet. 2.6 will include some of the newer libraries/ideas present in 3.0, so you'll be better off for learning 3.0 than someone who's used to older verisons of Python. 3.0 will not be mainstream for at least a year or two (someone like m0nk3yz or king_kilr will have a better estimate, probably). I can't really speak intelligently for other libraries but Django's current trajectory is to start having a 3.0 branch in about 1.5-2 years. That being said Martin Loewis has a patch available that combined with 2to3 brings Django to a usable state on 3.0, so if you had a pressing need(and it doesn't sound like you do) you could probably make it work.
|
# ? Jan 29, 2009 04:19 |
|
bitprophet posted:2.6. 3.0 is extremely new and almost nothing has been ported to it yet. 2.6 will include some of the newer libraries/ideas present in 3.0, so you'll be better off for learning 3.0 than someone who's used to older verisons of Python. 3.0 will not be mainstream for at least a year or two (someone like m0nk3yz or king_kilr will have a better estimate, probably).. If you want cleanliness and purity; go with 3.0 (note that IO speeds suck) - if you want third party code, libraries and frameworks, go with 2.6. Ultimately, to have strong python-fu, you'll need to know both.
|
# ? Jan 29, 2009 04:38 |
|
m0nk3yz posted:If you want cleanliness and purity; go with 3.0 (note that IO speeds suck) - if you want third party code, libraries and frameworks, go with 2.6. To add to this, the hope is to have 3.1 or a beta out around PyCon, this continues a lot of the cleanup that defined 3.0(plus io speedups and another 20% speed increase).
|
# ? Jan 29, 2009 04:59 |
|
supster posted:I'm sorry for asking probably previously-answered questions that no one likes to reanswer again... but: I think we need to put this in the first post. quote:(1) If I'm starting with Python, should I jump into 3.0 or 2.6? How common is it to not be able to find a 3.0 library for a common task that exists for 2.6? Python 2.6 and Python 3.0 are not really that different, and learning one is not significantly harder than learning both. You can install both of them, too. Still, it would be best to learn from 2.6 - there will be more documentation and libraries availiable. Even so it would be best to do with an aim towards python 3 - avoiding deprecated features (use the -3 warning flag) Python 3 is mainly a release to break backwards compatibility, many changes have made it into 2.6 also. Python 3.1 will be out soon with the io library re-written in c
|
# ? Jan 29, 2009 10:12 |
|
Kire posted:I'm making progress, thanks for the tip. When you print a dict, it prints the repr() of all of the keys and values within the dict. The repr() of a string in python 2.x will always escape non-printable and/or non-ASCII characters. You just need to print the string itself instead of the dict. Also, you should be using unicode strings. Prefixing each string literal with a u makes a string literal into a unicode literal. So, you would write u'Häuser'. This way, it'll work consistently across different terminals when you print the string. Of note: IDLE sucks at unicode. You might have to run your scripts in cmd to get the correct output.
|
# ? Jan 29, 2009 14:21 |
|
|
# ? May 9, 2024 17:53 |
|
I am gonna ask the boss for PyCon, and I am pretty sure I am going to go regardless of job paying for it, at the very least for the conference. That being said, this is discouraging. m0nk3yz do you think it'll be better this year?
|
# ? Jan 29, 2009 16:29 |