|
If you're coming from Mathematica, I would recommend reading up on both NumPy and SciPy.
|
# ? Jun 12, 2012 13:21 |
|
|
# ? May 9, 2024 12:35 |
|
duck monster posted:Anyone had any luck getting libtcod working on a mac. It seems like a phenomenal library, but the lake of Makefiles, setup.py's or any sort of install instructions (the download on the site of the prebuilt doesnt include the all important python wrappers ) makes it a total headfuck. I'd just recommend ditching libtcod and using pyglet or cairo.
|
# ? Jun 12, 2012 14:37 |
|
duck monster posted:Anyone had any luck getting libtcod working on a mac. It seems like a phenomenal library, but the lake of Makefiles, setup.py's or any sort of install instructions (the download on the site of the prebuilt doesnt include the all important python wrappers ) makes it a total headfuck. Sadly, no. It's been really infuriating for me as well.
|
# ? Jun 12, 2012 15:23 |
|
vikingstrike posted:If you're coming from Mathematica, I would recommend reading up on both NumPy and SciPy. Totally agreeing with this. NumPy and SciPy (mostly NumPy) are going to be *very* intuitive for you if you're used to the way mathematica thinks. It rules. Also, if you're using mathematica, chances are you are in a science field. What do you do? E: Really, I have been finding I use SciPy less and less. I guess if I had a reason to use their linalg package more, I'd use it. /shrug Also, you should totally get into matplotlib when you start to plot.
|
# ? Jun 12, 2012 17:07 |
|
duck monster posted:Anyone had any luck getting libtcod working on a mac. It seems like a phenomenal library, but the lake of Makefiles, setup.py's or any sort of install instructions (the download on the site of the prebuilt doesnt include the all important python wrappers ) makes it a total headfuck. Install the dependencies: brew install hg sdl cmake Get the source: hg clone https://bitbucket.org/jice/libtcod Build it: cd libtcod && cmake -G "Unix Makefiles" && make Copy the compiled library to the same place as the wrapper: ln -s src/libtcod.dylib . Run the sample: python samples_py.py Since there's no installer for the python wrapper, you then just have to copy the three required files (cprotos.py, libtcodpy.py, libtcod.dylib) into the appropriate place in your python environment. The sample requires the data directory as well.
|
# ? Jun 12, 2012 18:21 |
|
JetsGuy posted:Also, if you're using mathematica, chances are you are in a science field. What do you do? Just graduated from theoretical physics, and will possibly be doing something more computational next year. Someone in the group told me they use Python a lot so I thought I'd get on it.
|
# ? Jun 12, 2012 19:23 |
|
Starno posted:Just graduated from theoretical physics, and will possibly be doing something more computational next year. Someone in the group told me they use Python a lot so I thought I'd get on it. Being a scientist/engineer Python computational capabilities was the key feature which attracted me. It's very nice to see how Python takes over Fortran as de-facto standard of computational language.
|
# ? Jun 12, 2012 20:14 |
|
Starno posted:Just graduated from theoretical physics, and will possibly be doing something more computational next year. Someone in the group told me they use Python a lot so I thought I'd get on it. Graduated with my PhD in physics back in August! Congrats son! Python is quickly taking over IDL as the astronomer's choice language (especially amongst us younger ones). That said, I still have to use programs that aren't even available for download anymore that were written in FORTRAN 10,000BC because we astronomers, while we like new toys, are still lazy fucks. Tovarisch posted:Being a scientist/engineer Python computational capabilities was the key feature which attracted me. It's very nice to see how Python takes over Fortran as de-facto standard of computational language. I hate to say this, but MFIT still is the best fitting program out there, and it's written in loving f90 if you're lucky.
|
# ? Jun 12, 2012 20:32 |
|
Suspicious Dish posted:I'd just recommend ditching libtcod and using pyglet or cairo. Yeah Im not going to go and recreate a whole console library in open gl dude.
|
# ? Jun 12, 2012 20:52 |
|
curses? urwid?
|
# ? Jun 13, 2012 04:44 |
|
Plorkyeran posted:It doesn't seem to have any sort of support for actually installing it, but otherwise getting it working seemed simple. code:
Problem is, I have no idea how to coerce it to compile against the correct libpng This cmake poo poo is wierd as gently caress. duck monster fucked around with this message at 05:47 on Jun 13, 2012 |
# ? Jun 13, 2012 05:37 |
|
Try deleting the dependencies directory entirely and then doing a clean make. cmake appears to be picking up the (rather old) copy of libpng there rather than the system version. If it then can't find stuff, try running brew doctor and cpp -Wp,-v to verify that the paths are correct.
|
# ? Jun 13, 2012 06:14 |
|
Solved it. There where headers for loving monos platypus of a mutation of libpng on the path. So mono has been nuked , as a product roughly as useful as tits on a bull. And it all works now
|
# ? Jun 13, 2012 12:21 |
|
So, trying out Scientific Linux as a replacement for Fedora. Just got Numpy and Scipy built from source. Running tests, numpy.test() checks out fine, no failures, but scipy.test() returns 64 failures. Most of which look like the are raising AssertionError() that look like belowcode:
|
# ? Jun 13, 2012 21:10 |
|
vikingstrike posted:So, trying out Scientific Linux as a replacement for Fedora. Just got Numpy and Scipy built from source. Running tests, numpy.test() checks out fine, no failures, but scipy.test() returns 64 failures. Most of which look like the are raising AssertionError() that look like below Believe it or not, your problem may be in your fortran compiler... although the only times I've ever seen that was on OSX systems. The reason I bring it up is because the only time I ever saw an error like this (it was on stack, I think) was a result of using easy_install, which a lot of linux systems tend to love. EDIT: Yuppppp http://stackoverflow.com/questions/10797437/scipy-test-fails-with-many-assertion-errors http://projects.scipy.org/scipy/ticket/1476 http://projects.scipy.org/scipy/ticket/1496 http://projects.scipy.org/scipy/ticket/1618 you may wanna just try installing the latest gfortran and gcc. JetsGuy fucked around with this message at 23:55 on Jun 13, 2012 |
# ? Jun 13, 2012 23:53 |
|
vikingstrike posted:So, trying out Scientific Linux as a replacement for Fedora. Just got Numpy and Scipy built from source. Running tests, numpy.test() checks out fine, no failures, but scipy.test() returns 64 failures. Most of which look like the are raising AssertionError() that look like below Yeah, that kind of error looks quite fundamental and would make me wary about using SciPy and NumPy I'd compiled. As a workaround, would you consider using scipy from a repository? The EPEL scipy versions are quite old, but according to pkgs.org it looks like PUIAS has up to date versions of scipy and numpy for RHEL6. I'd suggest using those to avoid the headache of possible compilation problems. Also, could I ask why you've gone from Fedora to SL? I just made the opposite switch, from SL6.2 to Fedora 17, and I think I'm happier with Fedora.
|
# ? Jun 13, 2012 23:58 |
|
Thanks for the suggestions, guys! I am going to look into that repo you linked to, to see if I can get this sorted out. As for why I switched (I haven't yet, totally): I've been using Fedora for a couple of years as a dev environment/demo lab (I use OS X as my main desktop OS) and recently heard about SL. Since I was using it in a VM, I was interested to see if I saw any performance boost compared to Fedora and to get some Gnome 2 love. I'm still getting a feel for it, but it's been fine so far. The biggest difference is the lack of packages that are easy to find right off the bat for what I usually need (like right now, finding the right repo to look at). What do you enjoy about Fedora that SL lacks? edit: that repo worked, thanks for the heads up! vikingstrike fucked around with this message at 03:21 on Jun 14, 2012 |
# ? Jun 14, 2012 01:37 |
|
I'm using Iron Python to make a lot of calls to a web service with urllib2's urlopen function.Python code:
Edit: Switched to httplib and it's fine now Munkeymon fucked around with this message at 20:33 on Jun 15, 2012 |
# ? Jun 15, 2012 16:30 |
|
Any recommendations on a full flask web dev stack? Everything from data layer to javascript. I've been stuck in enterprise java hell and I've gotten behind on the cool stuff n
|
# ? Jun 16, 2012 18:07 |
|
Hammerite posted:Reading about strings and their literals at the moment. Is there a reason why in raw strings, the backslash escapes the string quote character, while being preserved in the string even when used in that way? It seems baffling. I realise that raw strings are just a convenience for more easily expressing some string literals and that there are plenty of ways around it. I'm new to Python, but I think that this page provides an answer. It's to do with the fact that raw strings are intended for use in regular expressions, in which backslashes are not valid as a final character. Or something. quote:In raw strings, backslashes do not have the magical power of escape characters that they do in regular strings. But they don’t lose all of their magical powers. In raw strings — as you discovered — backslashes have the magical power of protection characters. Basically, this means that a backslash protects any character that follows it from being recognized as the closing delimiter of the raw string.
|
# ? Jun 17, 2012 13:51 |
|
It makes Python easier to parse from all sides. That's it.
|
# ? Jun 17, 2012 17:40 |
|
crm posted:Any recommendations on a full flask web dev stack? Everything from data layer to javascript. I've been stuck in enterprise java hell and I've gotten behind on the cool stuff n Personally, I use Pyramid. But Flask doesn't have a terribly different stack, so here you go:
In general, check out the descriptions and links on flask extentions to see what plays nice with flask.
|
# ? Jun 18, 2012 00:25 |
|
I have an interesting problem that I think I know how to solve but I'm looking for thoughts before I start implementing. I have a large dictionary of Sessions, saved to the dict with their unique id. These Sessions will be called and updated in an unpredictable fashion, and the problem is how to purge the dictionary from Sessions that have been in memory for too long without updating, let's say 30 minutes. The solution I came up with would be to save all the Sessions in a list as well, and every time we update a Session we first access it from the dictionary, pop() it from the list based on the reference, update it, then insert it back to the list. All this should be O(1) complex, right? This way the oldest Sessions would be at the top of the list, and I could periodically iterate from the beginning of the list, removing all Sessions from the list and the dict until I encounter the first Session which has been updated in the last 30 minutes. I could do this with a simple if-clause that launches the purge pass every now and then, or maybe a separate thread that launches itself on a timer? I don't know poo poo about threading in Python though. The larger context for this is a Django web application which creates Sessions on my Python server but I don't know when the user abandons the web page by closing the browser or the computer, so there might be old unused Sessions in memory that no one is going to ever use again. I think there is some kind of reverse ajax call for polling the browser client if it still exists, but I dunno what would be a proper way to implement that. My webapp might not have more than a few dozen simultaneous users in the end, but I'd still like to implement this to be as rigid as possible even with something like 10000 users.
|
# ? Jun 18, 2012 12:22 |
|
Cukel posted:I have a large dictionary of Sessions, saved to the dict with their unique id. These Sessions will be called and updated in an unpredictable fashion, and the problem is how to purge the dictionary from Sessions that have been in memory for too long without updating, let's say 30 minutes. It's a little difficult to parse this, but a couple of notes: 1) If you have a list and you're removing items from the middle at random and moving them to the front, it's not O(1) since you're going to have to copy a bunch of elements after the removal 2) Just going through your dict every 2 or 3 minutes at O(n) is not going to be a big problem, and will be pretty easy to program, and if you're at the point where you're concerned about something like this, you're going to have other pretty big concerns (like how to cool your server farm) 3) Threading in cPython is basically a no-go (in most cases threading will actually slow down your program) because of the GIL
|
# ? Jun 18, 2012 12:53 |
|
Ok yeah, after your post I took another look at what I was doing and realized I was thinking it was more complicated than it actually is. Sorry if I was unclear. I'll just implement it as a simple O(n) search for Sessions that haven't been updated in a while. Ridgely_Fan posted:3) Threading in cPython is basically a no-go (in most cases threading will actually slow down your program) because of the GIL
|
# ? Jun 18, 2012 13:26 |
|
Cukel posted:This seems really weird to me - aren't there still use cases where you have to use threads, like listening sockets or something? I'm sure other people know more about this than me, but basically yeah the GIL only locks the interpreter, so it can get released if your thread is doing something other than processing Python. So listening to a socket, sleeping, calling C functions etc. can get the GIL released so other threads can run. Understanding threading in Python requires a better low level understanding of the language than I have though, maybe Suspicious Dish knows more.
|
# ? Jun 18, 2012 15:56 |
|
Without knowing anything about your server, I'm going to ask if you've looked into coroutines. gevent is my favorite library for using them, and they seem to work much better than threading in Python
|
# ? Jun 18, 2012 16:34 |
|
I don't really know how to use those so I'll have to look into them and see if it would make sense. Thanks.
|
# ? Jun 18, 2012 16:54 |
|
Twisted is also a very good option as well.
|
# ? Jun 18, 2012 19:43 |
Cukel posted:Stuff General FYI: You can cut the top k inactive sessions from an unsorted list using k-selection statistics (Selection Algorithm) in O(n) worst case. Probably not worth the hassle, though, since you're just cutting off at 30 minutes. I believe the general Python policy is "use processes, not threads", as Ridgely_Fan eluded to in his GIL comment. I don't know how you'd share the list across two processes in Django, but if it's DB side then there should be no issue in just importing the same models and performing manipulations in a separate Python function. It would be nice and clean to have a Python script attached to a Cron job performing maintenance.
|
|
# ? Jun 18, 2012 19:59 |
|
MeramJert posted:Without knowing anything about your server, I'm going to ask if you've looked into coroutines. gevent is my favorite library for using them, and they seem to work much better than threading in Python It's been a couple years since I did anything with coroutines. At the time I liked eventlets over gevent for some reason I can't remember. So...look at eventlets as well.
|
# ? Jun 18, 2012 21:33 |
|
Jo posted:I believe the general Python policy is "use processes, not threads", as Ridgely_Fan eluded to in his GIL comment. I don't know how you'd share the list across two processes in Django, but if it's DB side then there should be no issue in just importing the same models and performing manipulations in a separate Python function. It would be nice and clean to have a Python script attached to a Cron job performing maintenance.
|
# ? Jun 18, 2012 21:43 |
Cukel posted:That's a neat idea. Would be pretty easy if I can get a simple Python script to communicate with the Django database I'm running. I'm not sure how to do that without the usual development server stuff, so another thing to look into! I think (but have not tried recently) that if you do `from <myapp>.models import *`, then you can manipulate your models directly and perform changes DB side. However, I don't know if this can be run outside of Django's manage.py shell. I have a not so different problem. I have two support tasks that run along with the server. One of them spiders the web and adds pictures. The other iterates through the database and performs maintenance (remove old pictures, hash those which don't have features). I decoupled from Django because its ORM became problematic, but I'm certain you can still perform raw DB queries very easily.
|
|
# ? Jun 18, 2012 23:46 |
|
Cukel posted:That's a neat idea. Would be pretty easy if I can get a simple Python script to communicate with the Django database I'm running. I'm not sure how to do that without the usual development server stuff, so another thing to look into! Easiest way is to create a management command. If you want to use the ORM from completely stand-alone app (usually unnecessary), you should call code:
Cat Plus Plus fucked around with this message at 02:53 on Jun 19, 2012 |
# ? Jun 19, 2012 00:57 |
|
I have only used this briefly, but if you guys are trying to write code without the GIL slowing things down, there is the multiprocessing library. (Python 3 link)
|
# ? Jun 19, 2012 05:23 |
|
Titan Coeus posted:I have only used this briefly, but if you guys are trying to write code without the GIL slowing things down, there is the multiprocessing library. (Python 3 link) So whats the catch? Latency? Memory overhead? Data duplication? Something completely different? I am not saying those are necessarily an issue, I am just wondering what the trade-offs are. I have been using celery task queues to do some embarrassingly parallel processing, but this could be a better fit.
|
# ? Jun 19, 2012 08:40 |
|
PiotrLegnica posted:Easiest way is to create a management command. If you want to use the ORM from completely stand-alone app (usually unnecessary), you should call I did just realize a problem with the two processes communicating with the Sessions through the Django database ORM. For context: A Session is basically the object that's created every time someone starts or loads a new game in my web app. It contains all the game logic, interfaces, states, and such. It's updated every time the player sends an in-game command, so basically there's a lot of these Sessions created and they are updated very frequently, like probably one command every few seconds for just one user. Right now the Sessions are just kept in and updated from a dictionary and saved to the Django database only when the player saves the game. To save a Session in the Django database, I think I would have to use PickleField or other serialization methods. Would serializing and deserializing the Session every time it's updated be very costly performance-wise? TURTLE SLUT fucked around with this message at 12:39 on Jun 19, 2012 |
# ? Jun 19, 2012 12:36 |
|
So after a month of trying to learn C++ I burned out, I've always wanted to be a programmer but between work/home stress I just needed to take a break, a break that ended up lasting several months. I still want to learn how to program and would like to give it another shot. But I think I will take several people's advice and try a different language, Python is typically highly recommended. I have some free time at work and at home I could use to study and practice. Where should an absolute beginner start? I'd prefer to go with a book as opposed to an online guide but I wouldn't mind learning from an online source if it's really the best way to go, I can always print the current section I'm working through.
|
# ? Jun 19, 2012 17:02 |
|
Orange_Lazarus posted:So after a month of trying to learn C++ I burned out, I've always wanted to be a programmer but between work/home stress I just needed to take a break, a break that ended up lasting several months. I still want to learn how to program and would like to give it another shot. But I think I will take several people's advice and try a different language, Python is typically highly recommended. I have some free time at work and at home I could use to study and practice. The two best absolute beginner resources are: Think Python Learn Python The Hard Way They are books. On line. I don't know how that meshes with your preferences.
|
# ? Jun 19, 2012 17:17 |
|
|
# ? May 9, 2024 12:35 |
Cukel posted:Ok, neat, thanks. Are you not storing the individual sessions as Django objects? Could you do GameSession.objects.get(username="hurfdurf"), or something like it to grab a session?
|
|
# ? Jun 19, 2012 18:32 |