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
king_kilr
May 25, 2007

Habnabit posted:

Well, hey, at least my code is linear.

Is this backwards land? Twisted code is almost universally non-linear, whereas eventlet code tends to be linear.

Adbot
ADBOT LOVES YOU

Habnabit
Dec 30, 2007

lift your skinny fists like
antennas in germany.

king_kilr posted:

Is this backwards land? Twisted code is almost universally non-linear, whereas eventlet code tends to be linear.

Nope! eventlet causes magical context switches between coroutines. With twisted, you can follow your code's execution path exactly. It's not obvious from reading eventlet code which lines and/or functions can cause a context switch.

Besides, haven't you heard of inlineCallbacks?

king_kilr
May 25, 2007
Yeah I've used inlineCallbacks, and they improve the situation markedly, but there's still tons of twisted code out there using callbacks.

Yakattak
Dec 17, 2009

I am Grumpypuss
>:3

I've compiled and installed MySQL and I KNOW mysql_config is there and I KNOW it's just mysql_config, yet pip nor setup.py can seem to find it.

I've gotten it installed, but now when I try to import it, I get this:

code:
Python 2.6.5 (r265:79359, Mar 24 2010, 01:32:55) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import oursql
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/oursql.so, 2): Symbol not found: _mysql_affected_rows
  Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/oursql.so
  Expected in: dynamic lookup
:negative:

Yakattak fucked around with this message at 19:58 on Jun 5, 2010

Habnabit
Dec 30, 2007

lift your skinny fists like
antennas in germany.

Yakattak posted:

:words:

Well, that's certainly interesting. What version of OS X are you on, how did you install python, and do you have multiple mysqls installed? This just seems like a really wacky setup to me; I develop on OS X and I've never had problems building or installing oursql.

From the dlopen error, it looks to me like oursql.so wasn't linked against the right libmysqlclient.

Yakattak
Dec 17, 2009

I am Grumpypuss
>:3

Habnabit posted:

Well, that's certainly interesting. What version of OS X are you on, how did you install python, and do you have multiple mysqls installed? This just seems like a really wacky setup to me; I develop on OS X and I've never had problems building or installing oursql.

From the dlopen error, it looks to me like oursql.so wasn't linked against the right libmysqlclient.

So I should probably remove MySQL entirely and reinstall. It's very possible, I tried installing multiple times.

Scaevolus
Apr 16, 2007

Does Twisted have documentation yet?

Habnabit
Dec 30, 2007

lift your skinny fists like
antennas in germany.

Scaevolus posted:

Does Twisted have documentation yet?

I was going to link to each project's howtos and examples, but, effort.
http://twistedmatrix.com/trac/wiki/Documentation

tef
May 30, 2004

-> some l-system crap ->
the finger tutorial reads like the classic 'evolution of a programmer' as more and more unnecessary code gets added.


edit: this feels so java like, it's uncanny.

tef fucked around with this message at 01:26 on Jun 6, 2010

unixbeard
Dec 29, 2004

Yakattak posted:

I've compiled and installed MySQL and I KNOW mysql_config is there and I KNOW it's just mysql_config, yet pip nor setup.py can seem to find it.

I've gotten it installed, but now when I try to import it, I get this:

code:
Python 2.6.5 (r265:79359, Mar 24 2010, 01:32:55) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import oursql
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/oursql.so, 2): Symbol not found: _mysql_affected_rows
  Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/oursql.so
  Expected in: dynamic lookup
:negative:

its looking for the mysql so but cant find it, set your LD_LIBRARY_PATH environment variable to where the mysql libs are installed and restart python

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



I have a model made with Elixir that runs against a Postgres database. I wrote a script that uses this model to update some rows, and while printing out what it's doing. However, this only works when run in a terminal, if the output is piped or redirected to a file, I get this nonsense all the time:

Traceback (most recent call last):
File "~/genre_fix.py", line 32, in <module>
print "\tSetting genre for %s" % product
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 63: ordinal not in range(128)

Can I force UTF-8 output from Python in a better way than this:

code:
import sys
import codecs
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
which is a little annoying to have to remember to put in everything.

Bohemian Cowabunga
Mar 24, 2008

I have got a small script i use to right-click upload files to my ftp-server that works just fine except for one thing; if the file already exists it gets overwritten.

I am using this script to backup when writing my assignments etc. due to paranoia after losing a major project to a failed harddrive.

Now what i would like to do is to add a time stamp in the form of YearMonthDayTime in numeric ie. 201025041130 to the front of the filename
The script i am using, is one i have modified from http://zephyrfalcon.org/weblog/arch_d7_2003_06_28.html#e262

Having never really done anything like this before, I am seeking help with two things:

1. How do i get the date and time in the format i want? I know i can get the ticks from time.time() but is there a better/simpler way?

2. How do i rename a filename?

code:
import ftplib
import os
import sys
import traceback

ftp = ftplib.FTP()
ftp.connect('ftp.myhost.com', 21)
try:
    try:
        ftp.login('username','password')
       	ftp.cwd('Uploads')             
	fullname = sys.argv[1]
        name = os.path.split(fullname)[1]
        f = open(fullname, "rb")
        ftp.storbinary('STOR ' + name, f)
        f.close()
    finally:
        ftp.quit()
except:
    traceback.print_exc()

yatagan
Aug 31, 2009

by Ozma
This will be good reading:
http://docs.python.org/library/datetime.html

As will this:
http://docs.python.org/library/ftplib.html

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

Bohemian Cowabunga posted:

I have got a small script i use to right-click upload files to my ftp-server that works just fine except for one thing; if the file already exists it gets overwritten.

I am using this script to backup when writing my assignments etc. due to paranoia after losing a major project to a failed harddrive.

Now what i would like to do is to add a time stamp in the form of YearMonthDayTime in numeric ie. 201025041130 to the front of the filename
The script i am using, is one i have modified from http://zephyrfalcon.org/weblog/arch_d7_2003_06_28.html#e262

Having never really done anything like this before, I am seeking help with two things:

1. How do i get the date and time in the format i want? I know i can get the ticks from time.time() but is there a better/simpler way?

2. How do i rename a filename?

code:
import ftplib
import os
import sys
import traceback

ftp = ftplib.FTP()
ftp.connect('ftp.myhost.com', 21)
try:
    try:
        ftp.login('username','password')
       	ftp.cwd('Uploads')             
	fullname = sys.argv[1]
        name = os.path.split(fullname)[1]
        f = open(fullname, "rb")
        ftp.storbinary('STOR ' + name, f)
        f.close()
    finally:
        ftp.quit()
except:
    traceback.print_exc()

If I were you, I'd use a distributed version control system (I prefer Git) and use the VCS to synchronize multiple copies of your files. I've stored all of my course work in Git for the last two years, and it's been great. I even have multiple remote repositories that I push to.

MaberMK
Feb 1, 2008

BFFs

Carthag posted:

I have a model made with Elixir that runs against a Postgres database. I wrote a script that uses this model to update some rows, and while printing out what it's doing. However, this only works when run in a terminal, if the output is piped or redirected to a file, I get this nonsense all the time:

Traceback (most recent call last):
File "~/genre_fix.py", line 32, in <module>
print "\tSetting genre for %s" % product
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 63: ordinal not in range(128)

Can I force UTF-8 output from Python in a better way than this:

code:
import sys
import codecs
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
which is a little annoying to have to remember to put in everything.

First of all, use code tags around your traceback. Second:

code:
print u"\tSetting genre for %s" % product

Lurchington
Jan 2, 2003

Forums Dragoon
Ok, this is kind of specific to lxml but I had difficulty finding a straight answer using google.

What's the best way to check if lxml.etree.parse() successfully parsed a document?

I have a unittest where this block of code is tested:

code:
with closing(api_query(*args, **kwargs)) as xml_result:
    parsed_xml = etree.parse(xml_result)
    log.debug(etree.tostring(parsed_xml))
    self.assertTrue(isinstance(parsed_xml, etree.ElementBase),
                    "%s gives invalid data"%xml_result.geturl())
it looks fine on printout, but the isinstance() fails and I guess there's probably a better way. Is it safe to assume that if there's no exception, it was correctly parsed?

Chris Awful
Oct 2, 2005

Tell your friends they don't have to be scared or hungry anymore comrades.
I encountered something weird with Python.

This first block will load an image using the Image module(Image.tostring), but fails to load another image of the same file type. If I use tostring with no arguments, all images load, but some fail to load properly - showing parts of another image as if there is some kind of buffer issue, yet loading some others w/o issue.
code:
poo = open(filename)
image.sizeX = poo.size[0]
image.sizeY = poo.size[1]
image.data = poo.tostring("raw", "RGBA")
However Pygame is capable of loading all images w/o issue.

code:
poo = pygame.image.load(filename)
image.sizeX = poo.get_width()
image.sizeY = poo.get_height()
image.data = pygame.image.tostring(poo, "RGBA", True)
Was I doing something wrong?

Chris Awful fucked around with this message at 19:10 on Jun 9, 2010

tef
May 30, 2004

-> some l-system crap ->

Lurchington posted:

it looks fine on printout, but the isinstance() fails and I guess there's probably a better way. Is it safe to assume that if there's no exception, it was correctly parsed?


Check the output to a known clean parse? I've only seen lxml break by throwing an exception.

Lurchington
Jan 2, 2003

Forums Dragoon
Thanks for the suggestion, I'm using this to confirm getting good data from a web api I don't own, and I may need to rethink the best way to unit test it.

Thermopyle
Jul 1, 2003

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

This is a "point me in the right direction" question...

I'd love to be able to analyze a video file and determine to some decent degree of accuracy if it contains a station logo (like if it says NBC or SyFy). I don't really care about what logo it is, just if it has a logo at all.

I realize this is a fuzzy and ongoing area of research, but I'd at least like to experiment with it. Any libraries for this sort of thing? Any articles you can recommend? Any sort of pointers at all?

b0lt
Apr 29, 2005

Thermopyle posted:

This is a "point me in the right direction" question...

I'd love to be able to analyze a video file and determine to some decent degree of accuracy if it contains a station logo (like if it says NBC or SyFy). I don't really care about what logo it is, just if it has a logo at all.

I realize this is a fuzzy and ongoing area of research, but I'd at least like to experiment with it. Any libraries for this sort of thing? Any articles you can recommend? Any sort of pointers at all?

You can probably just use opencv's motion analysis restricted to each corner of the video looking for static elements.

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome
i am a big gay baby and don't understand how to transfer binary files over cgi

this is a cgi script that emits a dumb little spreadsheet via the magic of pyExcelerator.

code:
#!/usr/bin/python

import cgi
import MySQLdb
from pyExcelerator import *

def main():
	
	form = cgi.FieldStorage()
	if form.has_key("start") and form.has_key("end"):
		#ok go
		print('Content-Type: application/vnd.ms-excel\n\n');
		start = cgi.escape(form["start"].value)
		end = cgi.escape(form["end"].value)

		wb = Workbook()
		ws0 = wb.add_sheet('0')
		for x in range(10):
			for y in range(10):
	    # writing to a specific x,y
				ws0.write(x,y,"start end  %s, %s" % (start,end))
		wb.save('/tmp/output.xls')
		f = open('/tmp/output.xls','rb')
		write(f.read())
		f.close()
		
	else:
		#barf
		print('Content-Type: text/plain\n\n');
		print('usage: budgetSpreadsheet?start=[start date]&end=[end date]');
	
main()
if I look at /tmp/output.xls, it's awesome. But when I hit the cgi script and it comes in over the browser, it's all corrupted.

I assume it's got something to do with text conversions writing out over stdout, but I don't know how to avoid this issue.

unixbeard
Dec 29, 2004

does it help if you turn off binary mode on the open?

what is the os of the server and target client? if the server is unix technically you should have \r\n wherever you have \n

unixbeard fucked around with this message at 18:54 on Jun 11, 2010

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

unixbeard posted:

does it help if you turn off binary mode on the open?

nay.

quote:

what is the os of the server and target client? if the server is unix technically you should have \r\n wherever you have \n

did that, didn't really do anything.

I've seen some discussion about this with returning images instead of text and they typically use a StringIO object to write and read from. I can't (easily) do this because the Workbook object just has the 'save(filename)' function and doesn't really take any old output stream. I'd imagine the StringIO object deals with teh base64 encoding or whatever it is that has to happen to enable the transfer of a binary all on its own.

unixbeard
Dec 29, 2004

yeah if it isn't \n translation its probably something to do with encoding or character sets. if you're writing it to a file anyway can you read it back in and write it to the client with StringIO?

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome
:siren: :siren: STARTLING REVELATION: it only wants \r\n. \n\n is no good. \r\n\r\n is no good. Only \r\n. porblem sloved, thanks unixbeard and melonhead in irc .:siren: :siren:

unixbeard
Dec 29, 2004

the best kind of correct. i hate poo poo like this too, whatever happened to being strict about what you send but relaxed about what you accept

a cyberpunk goose
May 21, 2007

I'm not 100% sure if this is the right place for this, but it's python so heyy.

I'm making a game program that embeds python (I'm aware of how looked down upon this is) with boost::python, and stackless python.

Something I have going for me is Asynchronous resource loading (C/C++ threads), and one thing I'm going to need is the ability to load precompiled .pyc files into memory and have python ingest them at some point. What I'm not sure of, is how to feed python a buffer of data that is supposedly a .pyc

I haven't torn into the source code yet and my answers are definitely in there, I just figured there might be some magic Python function on the C side of things that will just magically work for eating precompiled scripts.

Threep
Apr 1, 2006

It's kind of a long story.

Mido posted:

a game program that embeds python (I'm aware of how looked down upon this is)
You'll have to explain this because I've been looking into doing the same and I've heard nothing of this sort, not that I've looked. All I know is that Civ4 and EVE both do it.

quote:

Something I have going for me is Asynchronous resource loading (C/C++ threads), and one thing I'm going to need is the ability to load precompiled .pyc files into memory and have python ingest them at some point. What I'm not sure of, is how to feed python a buffer of data that is supposedly a .pyc

I haven't torn into the source code yet and my answers are definitely in there, I just figured there might be some magic Python function on the C side of things that will just magically work for eating precompiled scripts.
I'm pretty sure it's PyImport_ExecCodeModule called directly on the pyc data

a cyberpunk goose
May 21, 2007

Threep posted:

You'll have to explain this because I've been looking into doing the same and I've heard nothing of this sort, not that I've looked. All I know is that Civ4 and EVE both do it.

boost::python is your friend. I can walk you through it in a few lines.

DISCLAIMER: I have no clue what I am doing, I'm probably doing it all wrong, but people dont normally do this so I'm not aware of the right way. The model of my game is one that allows users to propogate user-made content (which includes :siren: scripts :siren: in a few contexts), so I made some steps to protect the client-end from potentially malicious python scripts that could attempt to wreak havoc upon the end machines (unlikely but I'd hate myself if it happened).

Get and setup boost python, it's incredible! But a little weird to compile at first.

THE BASICS
code:

void test_func() {
    std::cout << "Hello world" << std::endl;
}

int main(char* argv, int argc) {
    Py_Initialize();
    boost::python::object main = boost::python::import("__main__");
    {
        scope within(main);
        def("testfunc",&test_func);
    }
    boost::python::exec("testfunc()",&main,&main);
    return 0;
}
If I remember anything correctly, that should spit out Hello World. I'm running off the top of my head here, but that's the jist if how you can essentially begin an embedded interpreter. I have a Resource class that loads my scripts and can compile them, it's Execute/Run function takes 2 pointers to the local/global modules that the script should operate under. I generally feed them the exact same thing for both since it meets my needs.

What I personally did was make a Simulation object to handle a lot of the 'heavy lifting' relating to setting up and managing the script execution and memory. I personally needed the limitations I talked about way above, so I import the default __main__ module and tweak it a bit, then use it for future script executions as the global/local module.

LIMITING THE INTERPRETER
Ugly code that I commented just for you! :j:
code:
Py_NoSiteFlag = true;
Py_Initialize(); // Initialize the python VM

object dict;    // this is boost::python::object
object builtins;
object main = import("__main__"); // boost::python::import

dict = main.attr("__dict__"); // get the __dict__ attribute from our imported __main__
builtins = dict["__builtins__"]; // get the __builtins__ object outta the above
{
	scope within(builtins); // scope into builtins so any thing we define/declare overwrites
	//TODO: overload everything important here
	// the following 'defines' a function in python, ie:
	// > def test_func():
	// but you can bind the call to a c function thanks to boost::python magic
	def("test_func",&TestFunction); // a test function
	def("file",&_overloaded_file_); // override the default 'file' object
	def("close",&_overloaded_close_); // override the file close object
	def("open",&_overloaded_open_); // override basic file operations
	def("__import__",&_overloaded_import_); // most importantly, override the ability to do a default (unsafe) import
}
PyObject* new_module = PyModule_New("_private_"); // make a new module called _private_ (this line right here is NOT boost::python)
if (!new_module) { // if it failed
	mInitialized = false; // the simulator isn't initialized, something went wrong
	return; // there is actual exception handling around this but I didnt include it
}
// some boost python magic in this bitch

// mRestrictedDictionary is a member of Simulator, it's a boost::python::object
// we use a classic CPython function, PyModule_GetDict to gain a reference from the vm, to our new _private_ module
// then incref it, then make a boost::python::handle<> to it, then feed that handle to the boost::python::object ctor
// which makes a reference object
// therse probably an awesomely simple way to do all this
mRestrictedDictionary = object(handle<>(incref(PyModule_GetDict(new_module))));
// swap out our blank _private_ module's __builtins__ with our new 'limited' one
mRestrictedDictionary["__builtins__"] = dict["__builtins__"]; 




// here's an example of one of the def overloads, __import__
// this will restrict me from doing any imports
// however, import [x] from [y] still seems to dodge this a little but not succeed
// I have not torn apart why, yet

	PyObject *_overloaded_import_(
		const char *name,
		PyObject *globals,
		PyObject *locals,
		PyObject *fromlist
		)
	{
		std::cout << "Import called! (" << name << ")" << std::endl;
		
		return globals;
	}
I can then call boost::python::exec(my_huge_script_here,[pointer to mRestrictedDictionary],[pointer to mRestrictedDictionary])

So now that I have some boost::python::objects that are effectively modules, I can get to work on executing 'safe' code that can be run with limited functionality!

I don't know if my module-slashing is fool proof from an entirely script-breaking-out-of-it's-cage standpoint, but I haven't realized of a good way to circumvent not having and file open/close functions, much less import.

EVE's usage of python is an interesting topic. From the near beginning they have used an awesome addition to python called Stackless Python, which I am personally using as well (for server AND clientside, which you will see in a second). Originally they used Stackless with pretty standard I/O objects for doing SQL stuff, file reads and writes, all the normal bottle-necky stuff. As you may or may not know, python is limited to 1 thread, as there is a GIL (Global Interpreter Lock), preventing shared script execution in a single memory space. Stackless was invented, which is essentially internalized microthreads with some goddamn amazing features, but it all still runs on one thread (but that doesn't mean it's not awesome).

What Stackless lets you do, is make these things called tasklets which work a lot like c-style threads (you start a function as a thread and it just goes, with the added bonus of being able to start object-instance-methods as threads and it works like you'd expect it to), but instead of just plowing through a loop that locks the whole thread that Python is on, you can use these things in Stackless called Channels, which are essentially really weird mutexes. If I have 30 entities that I only want thinking once per tick, I have them Receive on a single channel that they all reference, and while they are receiving, that Channel becomes imbalanced (each receive pushes it away from 0, each send you call, pushes it closer). Channels are effectively communication channels, but in common usage they are used as I describe them, as tasklet control.

So to summarize, I spawn 30 entities that imbalance a single Channel object by Receiving on it (requiring some code some where to call Send for every Recieve that was called), otherwise the tasklets will ignored until they get Sent something from that Channel. It's quite elegant when it all plays out, this behavior is normally aliased as a BeNice() function, and your main loop balanced that Channel every frame.

Anyway, the EVE guys were running into bottlenecks with the vanilla Stackless implementation, so they set to work on abstracting alot of the I/O functionality with true c-threaded object-wrappers that dramatically increased the performance of their servers and effectively flipped a switch ending all dramatic game-breaking lag on EVE.

Tasklets can do tons of other amazing things like having their execution state being Pickled (serialized) to a stream, and potentially resumed elsewhere (on other architectures even, as python is a VM).

If you wanted you could write a lazy file-saving utility by just pickling your root gamestate tasklet, assuming it's built on stackless.

Welp, enough :words: for now, I didnt structure that very well and it's pretty vague but I hope it's useful to someone.

a cyberpunk goose fucked around with this message at 13:52 on Jun 17, 2010

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

That looks all very helpful, but this:

Mido posted:

As you may or may not know, python is limited to 1 thread

is still not true.

Stabby McDamage
Dec 11, 2005

Doctor Rope

Jonnty posted:

That looks all very helpful, but this:


is still not true.

It's true if you want to use multithreading to achieve multi-core concurrency, which is an extremely common use case.

Let's not get into this again. Short story: CPython's Global Interpreter Lock (GIL) means that only one thread at a time can be executing Python code. Threads can still be used for separating tasks logically and interleaving IO with computation. Further, full processes may be used to achieve true processing concurrency, if needed. Some other python implementations, while having slower serial processing performance, do not have this particular limitation. The end.

EDIT: Added the words "Python" and "some" to make the above hair-splittingly correct.

Stabby McDamage fucked around with this message at 23:19 on Jun 17, 2010

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

Stabby McDamage posted:

It's true if you want to use multithreading to achieve multi-core concurrency, which is an extremely common use case.

Let's not get into this again. Short story: CPython's Global Interpreter Lock (GIL) means that only one thread at a time can be executing code. Threads can still be used for separating tasks logically and interleaving IO with computation. Further, full processes may be used to achieve true processing concurrency, if needed. Other python implementations, while having slower serial processing performance, do not have this particular limitation. The end.

We've all seen the slideshow, but the slideshow explicitly states that Python can use more than one thread. That was all I was querying.

Benji the Blade
Jun 22, 2004
Plate of shrimp.
Two important corrections here:

Stabby McDamage posted:

Short story: CPython's Global Interpreter Lock (GIL) means that only one thread at a time can be executing code.

Only one thread at a time can be executing code inside the Python interpreter. Lots of CPython code spends a lot of its time in C modules that release the lock on the interpreter, like NumPy, I believe. This is not, however, universally true about all C modules. I believe CPython's re module generally doesn't release the GIL.

It still sucks, of course, but significantly less for certain workloads.

Stabby McDamage posted:

Other python implementations, while having slower serial processing performance, do not have this particular limitation.

That's not strictly true either. Stackless and PyPy both, last I heard, have GILs. I believe you're right about Jython and IronPython, though.

ToxicFrog
Apr 26, 2008


Threep posted:

You'll have to explain this because I've been looking into doing the same and I've heard nothing of this sort, not that I've looked. All I know is that Civ4 and EVE both do it.

The general mantra for Python is "extend, don't embed", in large part because python's large footprint makes it more suitable as an apps language in its own right than as a language for embedding in other apps. (I am told that the CPython C API, at least, is also quite unpleasant compared to languages originally designed for embedding). Depending on what you're doing and what python implementation you're using, the GIL can also be a pain in the rear end.

Thus, you tend to see Python used a lot for entire apps, calling out to C modules as needed, whereas for embedding, languages like Lua have a much greater presence (and you may note that Civ5 is moving to Lua due to performance concerns with embedded Python).

king_kilr
May 25, 2007

Benji the Blade posted:

That's not strictly true either. Stackless and PyPy both, last I heard, have GILs. I believe you're right about Jython and IronPython, though.

PyPy has a GIL (for now), and Stackless is just a CPython fork to add... stackless so it still has the CPython GIL as well. Jython and IronPython do not have GILs however.

Thermopyle
Jul 1, 2003

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

I hate web design with a passion.

What's the best library or framework for abstracting away as much of it as possible?

Something useful for getting input from a user via forms or whatever web magic is possible and displaying results to them.

I'm not horribly concerned with making it beautiful, just functional.

tripwire
Nov 19, 2004

        ghost flow

Thermopyle posted:

I hate web design with a passion.

What's the best library or framework for abstracting away as much of it as possible?

Something useful for getting input from a user via forms or whatever web magic is possible and displaying results to them.

I'm not horribly concerned with making it beautiful, just functional.

Django?

a cyberpunk goose
May 21, 2007

tripwire posted:

Django?

Django!! :woop:

Adbot
ADBOT LOVES YOU

jupo
Jun 12, 2007

Time flies like an arrow, fruit flies like a banana.
Been hearing pretty good things about SQL on Rails, have you had a look at it?

  • Locked thread