Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
vikingstrike
Sep 23, 2007

whats happening, captain
If you're coming from Mathematica, I would recommend reading up on both NumPy and SciPy.

Adbot
ADBOT LOVES YOU

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

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.

Hubis
May 18, 2003

Boy, I wish we had one of those doomsday machines...

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've had no joy at all :(

Sadly, no. It's been really infuriating for me as well.

JetsGuy
Sep 17, 2003

science + hockey
=
LASER SKATES

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.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

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've had no joy at all :(
It doesn't seem to have any sort of support for actually installing it, but otherwise getting it working seemed simple.

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.

davebees
Feb 18, 2009

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.

Exergy
Jul 21, 2011

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.

JetsGuy
Sep 17, 2003

science + hockey
=
LASER SKATES

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.

:hfive: 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. :v:


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.

duck monster
Dec 15, 2004

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.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
curses? urwid?

duck monster
Dec 15, 2004

Plorkyeran posted:

It doesn't seem to have any sort of support for actually installing it, but otherwise getting it working seemed simple.

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.

code:
$ python2.6 samples_py.py 
libpng warning: Application built with libpng-1.2.46 but running with 1.5.4
libtcod 1.5.1
SDL : cannot load data/fonts/consolas10x10_gs_tc.png
:( I don't really know where to start. Its definately got that font in the data/fonts/ directory off the dir its in, so I can only assume its got something to do with the libpng version.

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

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
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.

duck monster
Dec 15, 2004

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 :)

vikingstrike
Sep 23, 2007

whats happening, captain
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

code:
FAIL: test_arpack.test_symmetric_modes(True, <gen-symmetric>, 'd', 2, 'SA', None, 0.5, <function asarray at 0x17b5d70>, None, 'cayley')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/nose-1.1.2-py2.6.egg/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/lib64/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 249, in eval_evec
    assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err)
  File "/usr/lib64/python2.6/site-packages/numpy/testing/utils.py", line 1213, in assert_allclose
    verbose=verbose, header=header)
  File "/usr/lib64/python2.6/site-packages/numpy/testing/utils.py", line 677, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13
error for eigsh:general, typ=d, which=SA, sigma=0.5, mattype=asarray, OPpart=None, mode=cayley
(mismatch 100.0%)
 x: array([[ -4.37654593e+01,   1.93569050e-02],
       [ -6.76756743e+01,   1.10531582e-01],
       [ -3.92194572e+01,   1.32235717e-01],...
 y: array([[-6.99800566,  0.01935691],
       [-6.57812868,  0.11053158],
       [-3.77954962,  0.13223572],...
Anyone familiar with this? Is this something I should be worried about?

JetsGuy
Sep 17, 2003

science + hockey
=
LASER SKATES

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

code:
FAIL: test_arpack.test_symmetric_modes(True, <gen-symmetric>, 'd', 2, 'SA', None, 0.5, <function asarray at 0x17b5d70>, None, 'cayley')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/nose-1.1.2-py2.6.egg/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/lib64/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 249, in eval_evec
    assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err)
  File "/usr/lib64/python2.6/site-packages/numpy/testing/utils.py", line 1213, in assert_allclose
    verbose=verbose, header=header)
  File "/usr/lib64/python2.6/site-packages/numpy/testing/utils.py", line 677, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13
error for eigsh:general, typ=d, which=SA, sigma=0.5, mattype=asarray, OPpart=None, mode=cayley
(mismatch 100.0%)
 x: array([[ -4.37654593e+01,   1.93569050e-02],
       [ -6.76756743e+01,   1.10531582e-01],
       [ -3.92194572e+01,   1.32235717e-01],...
 y: array([[-6.99800566,  0.01935691],
       [-6.57812868,  0.11053158],
       [-3.77954962,  0.13223572],...
Anyone familiar with this? Is this something I should be worried about?

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

xPanda
Feb 6, 2003

Was that me or the door?

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

code:
FAIL: test_arpack.test_symmetric_modes(True, <gen-symmetric>, 'd', 2, 'SA', None, 0.5, <function asarray at 0x17b5d70>, None, 'cayley')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/nose-1.1.2-py2.6.egg/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/lib64/python2.6/site-packages/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py", line 249, in eval_evec
    assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err)
  File "/usr/lib64/python2.6/site-packages/numpy/testing/utils.py", line 1213, in assert_allclose
    verbose=verbose, header=header)
  File "/usr/lib64/python2.6/site-packages/numpy/testing/utils.py", line 677, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Not equal to tolerance rtol=4.44089e-13, atol=4.44089e-13
error for eigsh:general, typ=d, which=SA, sigma=0.5, mattype=asarray, OPpart=None, mode=cayley
(mismatch 100.0%)
 x: array([[ -4.37654593e+01,   1.93569050e-02],
       [ -6.76756743e+01,   1.10531582e-01],
       [ -3.92194572e+01,   1.32235717e-01],...
 y: array([[-6.99800566,  0.01935691],
       [-6.57812868,  0.11053158],
       [-3.77954962,  0.13223572],...
Anyone familiar with this? Is this something I should be worried about?


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.

vikingstrike
Sep 23, 2007

whats happening, captain
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

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



I'm using Iron Python to make a lot of calls to a web service with urllib2's urlopen function.

Python code:
while len(master_list) > 0:
	current = master_list.popleft()
	try:
		connection = urlopen(address.format(base_url, current))
		data = connection.read()
		connection.close()
	except IOError as oops: #etc...
Yeah, I know that try can be one line, but my problem is that sockets are never released (they pile up in CLOSE_WAIT state), and I was hoping explicitly calling close would help. Nope. So, the people who run the service are complaining that I'm slamming their server with my fearsome single threaded while loop, and I'd really rather not mess around with socket level bullshit to fix this. Any advice?

Edit: Switched to httplib and it's fine now

Munkeymon fucked around with this message at 20:33 on Jun 15, 2012

crm
Oct 24, 2004

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

JingleCreb
May 3, 2007

print('B', end = "")
while True: print('a', end = "")

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.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
It makes Python easier to parse from all sides. That's it.

Haystack
Jan 23, 2005





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:
  • Production server: Apache w/ mod_wsgi (or nginx with uwsgi)
  • Development server: The one that ships with flask
  • Css and java script: Webassets w/ flask_webassets
  • Database: Postgres with SQLalchemy and maybe flask_sqlalchemy
  • Process manager: Supervisor
  • Forms: Lots of options with no clear standout. Deform, WTForm, and more.

In general, check out the descriptions and links on flask extentions to see what plays nice with flask.

TURTLE SLUT
Dec 12, 2005

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.

Emacs Headroom
Aug 2, 2003

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.

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.

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

TURTLE SLUT
Dec 12, 2005

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
This seems really weird to me - aren't there still use cases where you have to use threads, like listening sockets or something?

Emacs Headroom
Aug 2, 2003

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.

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

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

TURTLE SLUT
Dec 12, 2005

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.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Twisted is also a very good option as well.

Jo
Jan 24, 2005

:allears:
Soiled Meat

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.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

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.

TURTLE SLUT
Dec 12, 2005

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.
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!

Jo
Jan 24, 2005

:allears:
Soiled Meat

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.

Cat Plus Plus
Apr 8, 2011

:frogc00l:

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:
django.core.management.setup_environ(settings_module)
before importing any database stuff.

Cat Plus Plus fucked around with this message at 02:53 on Jun 19, 2012

Titan Coeus
Jul 30, 2007

check out my horn
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)

Surface
May 5, 2007
<3 boomstick

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.

TURTLE SLUT
Dec 12, 2005

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
code:
django.core.management.setup_environ(settings_module)
before importing any database stuff.
Ok, neat, thanks.

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

Sephiroth_IRA
Mar 31, 2010
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.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

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.

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.

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.

Adbot
ADBOT LOVES YOU

Jo
Jan 24, 2005

:allears:
Soiled Meat

Cukel posted:

Ok, neat, thanks.

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?

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?

  • Locked thread