0

Here's my code in python:

for post in posts: ss = get_vector_local(word_list, status) # ss is a string if ss is not None: output_file.writelines(ss + '\n') 

But I need to write about 1GB file.

Do I need to rewrite the output part with python-C extension module to make the output faster?

2
  • 1
    Just a brief comment... you should check for None with the is operator instead of equality. For the main problem, I don't know but I stay around coz it's interesting. Commented Aug 7, 2014 at 7:12
  • 1
    I guess the answer depends a lot on the system and other external factors. I suggest you try both and profile (time) the code to see which is faster. Commented Aug 7, 2014 at 7:20

1 Answer 1

1

Paraphrasing Linus T., C is basically the most portable assembler and therefore beats python in pure computations hands down.

Your example on the other side deals with I/O and as long as python is able to feed the I/O buffers fast enough, there should only be a neglectable overhead compared to pure C.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.