Re: file seek is slow

2010-03-12 Thread Metalone
I almost wrote a long reply to all this. In the end it boils down to being concerned about how much overhead there is to calling a 'C' function. I assumed that file.seek() simply delegated to fseek() and thus was one way to test this overhead. However, I now think that it must be doing more and may

Re: file seek is slow

2010-03-11 Thread Metalone
I just tried the seek test with Cython. Cython fseek() : 1.059 seconds. 30% slower than 'C' Python f.seek : 1.458 secondds. 80% slower than 'C'. It is amazing to me that Cython generates a 'C' file that is 1478 lines. #Cython code import time cdef int SEEK_SET = 0 cdef extern from "stdio.h"

Re: file seek is slow

2010-03-11 Thread Metalone
I am assuming that Python delegates the f.seek call to the seek call in the MS C runtime library msvcrt.dll. Does anybody know a nice link to the Python source like was posted above for the BSD 'C' library? Ok, I ran some more tests. C, seek: 0.812 seconds // test from original post

Re: file seek is slow

2010-03-10 Thread Metalone
Thanks, Tim. Good to know. -- http://mail.python.org/mailman/listinfo/python-list

Re: file seek is slow

2010-03-10 Thread Metalone
f1_seek = f1.seek did not change the performance at all. As it turns out each call is only 646 nanoseconds slower than 'C'. However, that is still 80% of the time to perform a file seek, which I would think is a relatively slow operation compared to just making a system call. -- http://mail.python

file seek is slow

2010-03-09 Thread Metalone
I ran a comparison that timed 1e6 file seeks. The tests were run with Python 2.6.4 and Microsoft Visual C 6.0 on Windows XP with an Intel 3GHz single processor with hyperthreading. Results: C: 0.812 seconds Python: 1.458 seconds. difference = 0.646 seconds. If the file.seek is removed the

Re: Multiprocessing.Pipe is not concurrently bi-directional (design flaw?)

2010-03-02 Thread Metalone
Well, I just realized that I could use a separate pipe to send the result back. This might work ok. -- http://mail.python.org/mailman/listinfo/python-list

Multiprocessing.Pipe is not concurrently bi-directional (design flaw?)

2010-03-02 Thread Metalone
I wanted to use Multiprocessing.Pipe and Multiprocessing.Process to peform Actor style communication. However, I just can't get what I need done, and I think it is due to inherit problems with the design of Pipe. If I have a process like this def process1(conn): while True: msg = conn.

Problem with multiprocessing managers

2010-01-06 Thread Metalone
>From the documentation for Using a remote manager there is the following example code: from multiprocessing.managers import BaseManager import Queue queue = Queue.Queue() class QueueManager(BaseManager): pass QueueManager.register('get_queue', callable=lambda:queue) m = QueueManager(address=('',

Need help with multiprocessing.manager and passing the manager a multiprocessing.Connection

2010-01-06 Thread Metalone
The following code snippet is taken from the Python 2.6 multiprocessing documentation with a simple change and this change does not work. I would like to know how to make it work or something similar. I want to pass a Connection object to the MathsClass. I get the following error on Windows: Trac

Re: Is there a way to tell if a script has been run by Pythonw.exe instead of Python.exe?

2007-10-19 Thread Metalone
Thanks to all, I learned something in each post. When using py2exe to build an executable sys.executable does not provide the name of the python interpreter but the name of the executable generated by py2exe. -- http://mail.python.org/mailman/listinfo/python-list

Is there a way to tell if a script has been run by Pythonw.exe instead of Python.exe?

2007-10-18 Thread Metalone
In particular I want to know how to tell if reading and writing to the console can occur. Something like sys.isConsolePresent() -- http://mail.python.org/mailman/listinfo/python-list

Re: Python for Visual Basic or C# programmers

2006-06-01 Thread Metalone
Slight correction. " %d" % 123 is not quite equivalent to str(123) as it does not handle negative numbers the same way. I am not sure there is a simple direct equivalent. "%+d" % 123 --> "+123" always gives a sign. "%4d" % 123 --> " 123" "%4d" % -123 --> "-123" so this works if you you know how wi

Re: ctypes pointers and SendMessage

2006-06-01 Thread Metalone
Ok, I see what I did wrong. I forgot to define the _fields_ variable. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python for Visual Basic or C# programmers

2006-06-01 Thread Metalone
A.M wrote: > Hi, > > > > I am trying to find the equivalent functions such as vb's str or asc in > Python. Is there any resource that help me to find these kinds of functions > in Python faster? > > > > Thank you, > > Alan > > Alan Python has a str() function that is close to vb's str. The Pyth

ctypes pointers and SendMessage

2006-05-31 Thread Metalone
I would like to call windll.user32.SendMessageA(hwnd, win32con.WM_COMMAND, wParam, lParam) where lParam represents a pointer to an object. And also convert this pointer back to an object reference inside of wnd_proc def wnd_proc(hwnd, msg, wParam, lParam): So something like this: class X(Structur

Re: interactive shell -- reload definitions?

2006-05-10 Thread Metalone
Thanks everybody. -- http://mail.python.org/mailman/listinfo/python-list

interactive shell -- reload definitions?

2006-05-09 Thread Metalone
I have a question about the interactive Python shell. Is it possible to reload a file and get the new definitions. For example, if I do import xyz Then I find a bug in some function in xyz. So, I edit xyz.py I would like to reload the definitions in xyz.py without leaving my current shell sessi

Re: Queue limitations?

2006-03-16 Thread Metalone
This example is missing a few initialization details although they can possibly be inferred. For example is iq = imageQueue() but imageQueue does not have a put() method. Is SetQueue() called? Is iq.start() called? I like to see small, fully complete and tested examples. The following works using