Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Can you manipulate bits and memory directly using Python? If yes, wouldn't that be a best option to dealing with performance-critical spots than C bindings?

share|improve this question
3  
Based on what I've read about python, I think this is the one thing that python can't do, almost by design. –  joshin4colours Mar 10 '12 at 3:39
3  
Manipulating bits and memory is low level, but that doesn't mean it will improve performance much. –  Pubby Mar 10 '12 at 4:26
    
You can write your own extension in C and there manipulate bits and memory. docs.python.org/extending Are you sure you are cpu-bound and need this? –  gruszczy Mar 10 '12 at 13:48
    
I think it’s more gain to not bit-twiddle but use a C extension than to use bit-twiddling in Python. In fact, it may make the code slower. If you’re really into performance, consider using LLVM (possibly as JIT if the instructions are dynamic) but note that this makes your code much less portable. –  mirabilos Dec 6 '13 at 13:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.