[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4586: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4588: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4589: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4590: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
AI Challenge Forums • View topic - python & C using ctypes

It is currently Mon Jun 25, 2018 3:55 pm Advanced search

python & C using ctypes

New Language? Want more libraries? Post Here.

python & C using ctypes

Postby vladimirfol » Tue Oct 25, 2011 1:11 pm

I want to rewrite perforance important function (in my python Bot) on C.
i will compile C library source to shared objects library (*.so in linux, *.dll in Windows) on my own computer, send the lib to the server and will call functions from the library in python Bot (using module 'ctypes').

Can i do it? I had seen that using many languages is prohibition in orders.

Now i would like to ask some technical questions (honestly i never use *.so before):
will my library (compiled in my machine) work in the server?
do i understand clearly that some servers powered on Linux and other powered on Win? do i must to compile *.dll version of my lib too, or allservers powered on Linux?

sorry for my Eng.
vladimirfol
Cadet
 
Posts: 3
Joined: Tue Oct 25, 2011 12:54 pm

Re: python & C using ctypes

Postby vladimirfol » Thu Oct 27, 2011 6:21 pm

BUMP
vladimirfol
Cadet
 
Posts: 3
Joined: Tue Oct 25, 2011 12:54 pm

Re: python & C using ctypes

Postby amstan » Thu Oct 27, 2011 6:39 pm

There is no way for you to compile the C part on the server. So you'll have to provide a precompiled library. As long as it matches the server architecture you should be good.

We are using ubuntu 11.04, 64bit on the workers.
Alexandru M. Stan
Contest Organizer
User avatar
amstan
Contest Organizer
 
Posts: 691
Joined: Sun Jan 31, 2010 4:02 am
Location: Stoney Creek, Ontario

Re: python & C using ctypes

Postby vladimirfol » Thu Oct 27, 2011 9:56 pm

Thnx for u answer.

>64bit on the workers.
BTW, psyco module dont work on 64bit systems, its imports in the starting package may be misleading people about the speed of the program on the server
vladimirfol
Cadet
 
Posts: 3
Joined: Tue Oct 25, 2011 12:54 pm

Re: python & C using ctypes

Postby ebo^ » Fri Oct 28, 2011 5:14 pm

ebo^
Cadet
 
Posts: 1
Joined: Fri Oct 28, 2011 4:55 pm

Re: python & C using ctypes

Postby Janzert » Sat Oct 29, 2011 5:29 am

Just be sure your compile time stays under 3 seconds. :)

(or be prepared to go without until it does finish of course)
Janzert
Contest Organizer
 
Posts: 271
Joined: Sun Feb 07, 2010 1:59 am

Re: python & C using ctypes

Postby tmc » Sat Oct 29, 2011 6:36 am

Huh? I thought bots weren't allowed to write to files, and I figured that they wouldn't be allowed to spawn processes either, since that could lead to all sorts of cheating. For example, you could spawn a worker process for computations, or continue running between turns. And could running a compiler in the background steal time from other bots?

Anyway, how about a proper solution? I don't really want to have to install a 64 bit Ubuntu. compile.py could, if the (main) source language is Python, find any .c, .cc or .cpp files (or even better, .pxd Cython source files! But this isn't needed because you can just translate them to C on your local machine) and compile them to .so modules. I would just go implement this and submit a patch, it looks easy to implement. Except for one problem: you might not want to compile each C file to an individual .so file. How do we handle this? compile.py is very restrictive, but I understand that you don't actually want it to be? Since the compilers are sandboxed, how about allowing a setup.py build script for python submissions -- run it if it exists? Of course, no other language seems to support build scripts, so maybe that's not fair?
tmc
Brigadier-General
 
Posts: 101
Joined: Fri Oct 28, 2011 8:42 am

Re: python & C using ctypes

Postby Janzert » Sat Oct 29, 2011 8:09 am

Janzert
Contest Organizer
 
Posts: 271
Joined: Sun Feb 07, 2010 1:59 am

Re: python & C using ctypes

Postby tmc » Sat Oct 29, 2011 5:12 pm

tmc
Brigadier-General
 
Posts: 101
Joined: Fri Oct 28, 2011 8:42 am

Re: python & C using ctypes

Postby Parasprites » Sat Oct 29, 2011 5:35 pm

In order to preserve backwards compatibility, why not just introduce new file extensions? For example .cc11 could be C++ compiled with -std=c++0x
Parasprites
Major-General
 
Posts: 224
Joined: Mon Oct 24, 2011 3:08 pm

Next

Return to Language Support

Who is online

Users browsing this forum: No registered users and 2 guests

cron