General Python question

General discussion for off-topic subjects.
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

General Python question

Postby BackRaw » Fri Jul 20, 2012 10:07 pm

Hi,

is it faster to have a C++ code where you write boost.python mostly than to have Python code with the same?

Like

Syntax: Select all

import os

if __name__ == "__main__":
x = [3, 6, 7, 9]
z = os.getcwd()

# do something else like reading a file and display its contents to the screen
and

Syntax: Select all

#include <stdlib.h> // for getcwd()
#include <boost/python.hpp>

using namespace boost::python;

BOOST_PYTHON_MODULE(test) // or whatever you write the main thing in...
{
char path[1024];

list<int> x({4, 6, 7, 8}); // or however you initialize a list object directly, you know what I mean
getcwd(path, 1024);
str z(path);

// do something else like reading a file and display its contents to the screen
}

I wanna know if it makes a speed difference to have actually the same code in a C++ library.
your-name-here
Developer
Posts: 168
Joined: Sat Jul 07, 2012 1:58 am

Postby your-name-here » Fri Jul 20, 2012 10:21 pm

I am not sure. My guess is C++ will always be faster. Boost runs your code natively unlike a script which is run through the interpreter.
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Fri Jul 20, 2012 10:42 pm

your-name-here wrote:I am not sure. My guess is C++ will always be faster. Boost runs your code natively unlike a script which is run through the interpreter.


That's an argument! Thanks :)

Return to “Whatever”

Who is online

Users browsing this forum: No registered users and 10 guests