Re: ctypes help

2008-05-22 Thread sturlamolden
On May 23, 12:33 am, gianluca <[EMAIL PROTECTED]> wrote: > Hy, > I need help about use dll with ctypes. I've compiled my dll C library > and I copied it in c:\windows\system32. When I load it with > "myDLL=cdll.LoadLibrary(find_library("myDLL.dll"))" It seem all OK but > python don't see the dll fu

Re: Python is slow

2008-05-22 Thread sturlamolden
On May 22, 6:14 pm, cm_gui <[EMAIL PROTECTED]> wrote: > I've yet to see a web application written in Python which is really > fast. I bet you have a slow dial-up connection. -- http://mail.python.org/mailman/listinfo/python-list

Re: which datastructure for fast sorted insert?

2008-05-25 Thread sturlamolden
On May 25, 8:02 pm, Rodrigo Lazo <[EMAIL PROTECTED]> wrote: > what about heapq for sorting? Heap is the data structure to use for 'fast (nearly) sorted inserts'. But heapq do not support (as far as I know) deletion of duplicates. But a custom heap class coud do that of course. -- http://mail.pyt

Re: should I put old or new style classes in my book?

2008-05-30 Thread sturlamolden
On May 29, 6:07 pm, [EMAIL PROTECTED] wrote: > The current edition of the book presents old style classes. I am > considering > switching to new style classes on the assumption that this should be > the default > choice for new programs. The drawback is that a lot of the online > documentation >

Re: Why does python not have a mechanism for data hiding?

2008-06-03 Thread sturlamolden
On May 24, 3:41 pm, Sh4wn <[EMAIL PROTECTED]> wrote: > first, python is one of my fav languages, and i'll definitely keep > developing with it. But, there's 1 one thing what I -really- miss: > data hiding. I know member vars are private when you prefix them with > 2 underscores, but I hate prefixi

Re: Why does python not have a mechanism for data hiding?

2008-06-03 Thread sturlamolden
On Jun 2, 12:40 pm, Antoon Pardon <[EMAIL PROTECTED]> wrote: > I think you completed missed the point. > > This is just a proof of concept thing. In a real example there would > of course no Set en Get methods but just methods that in the course > of their execution would access or update the hidd

Re: How to perform a nonblocking read from a process

2008-06-03 Thread sturlamolden
On Jun 4, 3:20 am, [EMAIL PROTECTED] wrote: > It seems that stdout.readline() is a blocking read and it just gets > stuck their.. > How to fix this .. Threads are the simplest remedy for blocking i/o. -- http://mail.python.org/mailman/listinfo/python-list

Re: can python do some kernel stuff?

2008-06-03 Thread sturlamolden
On Jun 4, 12:41 am, Ethan Furman <[EMAIL PROTECTED]> wrote: > the kernel itself, *is* kernel coding. And as wonderful as Python is, > it is *not* for kernel coding. Not in its present form, no, it would take some porting. But aside from that, is there any reason one could not embed a python inte

Re: How to perform a nonblocking read from a process

2008-06-04 Thread sturlamolden
On Jun 4, 8:45 am, [EMAIL PROTECTED] wrote: > I've to admit I'm a newbie to this kind of programming... > what if I have to run thousands of these commands...it doesn't make > sense to create > thousands of threads.. > Is there a way that above mentioned piece of code be made to worked... Are yo

multiprocessing module (PEP 371)

2008-06-04 Thread sturlamolden
I sometimes read python-dev, but never contribute. So I'll post my rant here instead. I completely support adding this module to the standard lib. Get it in as soon as possible, regardless of PEP deadlines or whatever. I don't see pyprocessing as a drop-in replacement for the threading module. Mu

Re: how should i use this function?

2008-06-04 Thread sturlamolden
On Jun 4, 8:14 pm, Gandalf <[EMAIL PROTECTED]> wrote: > I tried to import win32ui.PyCRichEditCtrl, But the shell told me > their's no such module. There isn't, as it is a class. win32ui is a module. If you cannot import that, you don't have pywin32 installed. Go get it from Sourceforge. -- http

Re: multiprocessing module (PEP 371)

2008-06-04 Thread sturlamolden
On Jun 4, 11:29 pm, Paul Boddie <[EMAIL PROTECTED]> wrote: > tested the executable on Windows. COW (copy-on-write, for those still > thinking that we're talking about dairy products) would be pretty > desirable if it's feasible, though. There is a well known C++ implementation of cow-fork on Wind

Re: multiprocessing module (PEP 371)

2008-06-05 Thread sturlamolden
On Jun 5, 11:02 am, pataphor <[EMAIL PROTECTED]> wrote: > This is probably not very central to the main intention of your post, > but I see a terminology problem coming up here. It is possible for > python objects to share a reference to some other object. This has > nothing to do with threads or

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread sturlamolden
On Jun 5, 3:26 pm, Fuzzyman <[EMAIL PROTECTED]> wrote: > So, you are stating that no API programmer using Python *ever* has a > valid or genuine reason for wanting (even if he can't have it) genuine > 'hiding' of internal state or members from consumers of his (or > her...) API? > > Michael Foordh

Re: Summing a 2D list

2008-06-14 Thread sturlamolden
On Jun 12, 3:48 pm, Mark <[EMAIL PROTECTED]> wrote: > Is this possible? def foobar(user,score): sums = {} for u,s in zip(user,score): try: sums[u] += s except KeyError: sums[u] = s return [(u, sums[u]) for u in sums].sort() usersum = foobar(user,score) for

Re: GUI Programming by hand not code with Python Code

2008-07-08 Thread sturlamolden
On 7 Jul, 04:33, [EMAIL PROTECTED] wrote: > Is their a program that lets you design a GUI by hand (like gambas) > not by code (like wxpython) but the commands are in python? > > A program similar to gambas or vb > > Gambas with python code instead of gambas code would be perfect. > > Thanks in adv

Re: sage vs enthought for sci computing

2008-07-08 Thread sturlamolden
On 7 Jul, 22:35, [EMAIL PROTECTED] wrote: > Hello, > I have recently become interested in using python for scientific > computing, and came across both sage and enthought. I am curious if > anyone can tell me what the differences are between the two, since > there seems to be a lot of overlap (from

Re: Moving to functional programming

2008-07-11 Thread sturlamolden
On Jul 11, 12:00 pm, James Fassett <[EMAIL PROTECTED]> wrote: > tuple_list = ( >     ('John', 'Doe'), >     ('Mark', 'Mason'), >     ('Jeff', 'Stevens'), >     ('Bat', 'Man') >   ) > > # what I'd do in C or other procedural languages > result_list = [] > for item in tuple_list: >     result_list.a

Re: PyOpenGL Tutorial?

2008-07-25 Thread sturlamolden
On Jul 23, 10:07 pm, Clay Hobbs <[EMAIL PROTECTED]> wrote: > I need a tutorial for PyOpenGL (specifically, to be used with wxPython). > I searched with Google and didn't find one.  Does anybody know where one > is? PyOpenGL is just a wrapper for OpenGL. The API is identical. Do you need an OpenGL

Re: Python program as daemon?

2008-07-25 Thread sturlamolden
On Jul 25, 8:37 pm, Johny <[EMAIL PROTECTED]> wrote: > Is it possible to run a Python program as daemon? > Thanks Here is an example on how to run a Python script as a Unix daemon: http://svn.plone.org/svn/collective/bda.daemon/trunk/bda/daemon/daemon.py Basically it forks twice and redirects op

Re: 2d graphics - what module to use?

2008-07-25 Thread sturlamolden
On Jul 25, 8:13 am, Pierre Dagenais <[EMAIL PROTECTED]> wrote: > What is the easiest way to draw to a window? I'd like to draw something >   like sine waves from a mathematical equation. > Newbie to python. For mathematica equations, NumPy and matplotlib is probably the best option. I prefer to em

Re: 2d graphics - what module to use?

2008-07-26 Thread sturlamolden
On Jul 26, 6:47 am, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote: > If you're using wx, there is also wx.lib.plot, which I found to be > _much_ faster than matplotlib in my application, especially when resizing. Yes. Matplotlib creates beautiful graphics, but are terribly slow on large data sets

Re: random numbers according to user defined distribution ??

2008-08-07 Thread sturlamolden
Alex wrote: > I wonder if it is possible in python to produce random numbers > according to a user defined distribution? > Unfortunately the random module does not contain the distribution I > need :-( There exist some very general algorithms to generate random numbers from arbitrary distribution

Re: benchmark

2008-08-07 Thread sturlamolden
On Aug 7, 2:05 am, "Jack" <[EMAIL PROTECTED]> wrote: > I know one benchmark doesn't mean much but it's still disappointing to see > Python as one of the slowest languages in the test: > > http://blog.dhananjaynene.com/2008/07/performance-comparison-c-java-p... And how does this reflect the perfor

Re: ANN: pygame 1.8 released

2008-03-30 Thread sturlamolden
This is good news, particularly the NumPy support for surface and pixel arrays. -- http://mail.python.org/mailman/listinfo/python-list

Re: License of Python

2008-03-30 Thread sturlamolden
On 30 Mar, 17:16, iu2 <[EMAIL PROTECTED]> wrote: > Due to Competitors... I don't want to expost the language I use Either your comepetitors will figure it out, or they don't care. Using Python can be a major competitive advance. If your competitors are smart enough to realise that, you are in tro

Re: Creating a python c-module: passing double arrays to c functions. segmentation fault. swig

2008-03-30 Thread sturlamolden
On 30 Mar, 22:21, [EMAIL PROTECTED] wrote: > Hello everybody, > > I'm building a python module to do some heavy computation in C (for > dynamic time warp distance computation). Why don't you just ctypes and NumPy arrays instead? # double timewarp(double x[], int lenx, double y[], int leny); imp

Re: Creating a python c-module: passing double arrays to c functions. segmentation fault. swig

2008-03-31 Thread sturlamolden
On 31 Mar, 20:52, kim <[EMAIL PROTECTED]> wrote: > array_pointer_t = ndpointer(dtype=c_double) This one is wrong. The dtype should be the datatype kept in the array, which is 'float' (Python doubles) or 'numpy.float64'. array_pointer_t = ndpointer(dtype=numpy.float64) I'd take a good look at t

Re: Summary of threading for experienced non-Python programmers?

2008-04-02 Thread sturlamolden
On Apr 2, 1:26 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > It did *not* say that it supports every existing, more powerful and > generally better asynchronous mechanism supported by any OS out there. > Even though it would certainly be nice if it did :) Python's standard library should ha

Re: Importing a 3rd Party windows DLL for use within th Python

2008-04-04 Thread sturlamolden
On Apr 5, 12:58 am, [EMAIL PROTECTED] wrote: > Is it possible for someone to provide the information on the steps > necessary to access this DLL and treat it like any other pyd library? > Maybe there is already a tutorial available for performing this task? > Is this task straight forward? Short

Re: How is GUI programming in Python?

2008-04-11 Thread sturlamolden
On Apr 11, 8:35 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > wxDesigner. IMHO, wxFormBuilder is better. http://wxformbuilder.org/ http://preview.tinyurl.com/6l8wp4 -- http://mail.python.org/mailman/listinfo/python-list

Re: How is GUI programming in Python?

2008-04-11 Thread sturlamolden
On Apr 12, 12:32 am, Rune Strand <[EMAIL PROTECTED]> wrote: > produce "what I want" without _wasting life_. But Boa is too unstable, > and does not claim otherwise, and there's no descent alternative I'm > aware of. wxFormDesigner is the best there is for wx. QtDesigner ditto for Qt. Glade ditto

Re: How is GUI programming in Python?

2008-04-11 Thread sturlamolden
On Apr 11, 5:01 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > Another annoying thing with the Qt license is that you have to choose it > at the very start of the project. You cannot develop something using the > open source license and later decide to switch to the commercial licence > and

Re: Multiple independent Python interpreters in a C/C++ program?

2008-04-12 Thread sturlamolden
On Apr 11, 6:24 pm, [EMAIL PROTECTED] wrote: > Do I wind up with two completely independent interpreters, one per thread? > I'm thinking this doesn't work (there are bits which aren't thread-safe and > are only protected by the GIL), but wanted to double-check to be sure. You can create a new int

Re: Multiple independent Python interpreters in a C/C++ program?

2008-04-12 Thread sturlamolden
On Apr 11, 6:24 pm, [EMAIL PROTECTED] wrote: > Do I wind up with two completely independent interpreters, one per thread? > I'm thinking this doesn't work (there are bits which aren't thread-safe and > are only protected by the GIL), but wanted to double-check to be sure. You can create a new sub

C API design flaw (was: Re: Multiple independent Python interpreters in a C/C++ program?)

2008-04-12 Thread sturlamolden
On Apr 12, 7:05 pm, sturlamolden <[EMAIL PROTECTED]> wrote: > In theory, a GIL private to each (sub)interpreter would make Python > more scalable. The current GIL behaves like the BKL in earlier Linux > kernels. However, some third-party software, notably Apache's > mo

Re: Preferred method for "Assignment by value"

2008-04-15 Thread sturlamolden
On Apr 15, 7:23 pm, [EMAIL PROTECTED] wrote: > test = [[1],[2]] > x = test[0] Python names are pointer to values. Python behaves like Lisp - not like Visual Basic or C#. Here you make x point to the object which is currently pointed to by the first element in the list test. If you now reassign

Re: Preferred method for "Assignment by value"

2008-04-15 Thread sturlamolden
On Apr 15, 8:19 pm, [EMAIL PROTECTED] wrote: > Coming from VBA I have a tendency to think of everything as an > array... Coding to much in Visual Basic, like Fortran 77, is bad for your mind. -- http://mail.python.org/mailman/listinfo/python-list

I just killed GIL!!!

2008-04-16 Thread sturlamolden
Hello Guys... I just had one moment of exceptional clarity, during which realized how I could get the GIL out of my way... It's so simple, I cannot help wondering why nobody has thought of it before. Duh! Now I am going to sit and and marvel at my creation for a while, and then go to bed (it's pas

Re: How is GUI programming in Python?

2008-04-16 Thread sturlamolden
On Apr 16, 4:17 am, [EMAIL PROTECTED] wrote: > Reformulating my question: > > Which GUI tool, wxPython or PyQt, is more pythonic? (Please, ignore > the license issue because I am thinking about FOSS) None of them, all three of them (you forgot PyGTK), or it doesn't matter more. Nobody with their

Re: I just killed GIL!!!

2008-04-17 Thread sturlamolden
On 17 Apr, 15:21, "Martin P. Hellwig" <[EMAIL PROTECTED]> wrote: > If not, what is the advantage above already present solutions? Well... I like the processing module. Except that Wintendo toy OS has no fork() availabe for the Win32 subsystem, which makes it a bit limited on that platform (slow a

Re: I just killed GIL!!!

2008-04-17 Thread sturlamolden
On 17 Apr, 10:25, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > help progress at all. I think neither was the case in this thread - > the guy claimed that he actually did something about the GIL, and > now we are all waiting for him to also tell us what it is that he > did. Ok, I did not remove

Re: I just killed GIL!!!

2008-04-17 Thread sturlamolden
On 17 Apr, 09:11, Matias Surdi <[EMAIL PROTECTED]> wrote: > It's april 1st again??? Not according to my calendar. This was not meant as a joke. I think I may have solved the GIL issue. See my answer to Martin v. Löwis for a full explanation. -- http://mail.python.org/mailman/listinfo/python-lis

Re: I just killed GIL!!!

2008-04-17 Thread sturlamolden
On 17 Apr, 10:12, Steve Holden <[EMAIL PROTECTED]> wrote: > Quick, write it down before the drugs wear off. Hehe, I don't take drugs, apart from NSAIDs for arthritis. Read my answer to Martin v. Löwis. -- http://mail.python.org/mailman/listinfo/python-list

Re: I just killed GIL!!!

2008-04-17 Thread sturlamolden
On Apr 17, 5:46 pm, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > Have you tackled the communication problem? The way I see it, one > interpreter cannot "see" objects created in the other because they > have separate pools of ... everything. They can communicate by > passing serialized objects thro

Re: I just killed GIL!!!

2008-04-17 Thread sturlamolden
On Apr 17, 6:03 pm, Rhamphoryncus <[EMAIL PROTECTED]> wrote: > Interesting. Windows specific, but there's other ways to do the same > thing more portably. I believe you can compile Python as a shared object (.so) on Linux as well, and thus loadable by ctypes. > The bigger issue is that you can'

Re: I just killed GIL!!!

2008-04-17 Thread sturlamolden
On Apr 17, 7:16 pm, Jonathan Gardner <[EMAIL PROTECTED]> wrote: > On Apr 17, 8:19 am, sturlamolden <[EMAIL PROTECTED]> wrote: > > > > > An there you have the answer. It's really very simple :-) > > That's an interesting hack. > > Now, how

Re: I just killed GIL!!!

2008-04-18 Thread sturlamolden
On 18 Apr, 21:28, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Passing a NULL SectionHandle to NTCreateProcess/CreateProcessEx > results in a fork-style copy-on-write duplicate of the current process. I know about NtCreateProcess and ZwCreateProcess, but they just create an empty process - no

Re: why function got dictionary

2008-04-19 Thread sturlamolden
On Apr 17, 4:06 pm, AlFire <[EMAIL PROTECTED]> wrote: > Q: why function got dictionary? What it is used for? As previously mentioned, a function has a __dict__ like (most) other objects. You can e.g. use it to create static variables: int foobar() { static int i = 0; return i++; } is rou

Re: why function got dictionary

2008-04-19 Thread sturlamolden
On Apr 19, 8:33 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > barfoo = foobar > foobar = lambda x : x > > And boom. That's why I used the qualifier 'roughly equivalent' and not simply 'equivalent'. -- http://mail.python.org/mailman/listinfo/python-list

Re: I just killed GIL!!!

2008-04-19 Thread sturlamolden
On Apr 19, 10:29 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > FWIW, NT's POSIX subsytem fork() uses (or used to use) the NULL > SectionHandle method and was POSIX certified, so it's certainly > possible. Windows Vista Ultimate comes with Interix integrated, renamed 'Subsystem for Unix bas

Re: "Help needed - I don't understand how Python manages memory"

2008-04-20 Thread sturlamolden
On Apr 20, 2:46 pm, "Hank @ITGroup" <[EMAIL PROTECTED]> wrote: > That is my question, after ``del``, sometimes the memory space returns > back as nothing happened, sometimes not... ... > What exactly was happening??? Python has a garbage collector. Objects that cannot be reached from any scope is

Re: Any reliable obfurscator for Python 2.5

2008-04-20 Thread sturlamolden
On Apr 20, 5:28 pm, JB Stern <[EMAIL PROTECTED]> wrote: > Curious Steve, how do you pay the rent and by what authority do you > speak for "The Python world"? Your opinion couldn't be more wrong for > programmers like myself who live by the code they write (as opposed to > its support). Are you

Re: "Help needed - I don't understand how Python manages memory"

2008-04-20 Thread sturlamolden
On Apr 20, 9:09 pm, "Hank @ITGroup" <[EMAIL PROTECTED]> wrote: > Could you please give us some clear clues to obviously call python to > free memory. We want to control its gc operation handily as we were > using J**A. If you want to get rid of a Python object, the only way to do that is to get r

Re: Any reliable obfurscator for Python 2.5

2008-04-20 Thread sturlamolden
On Apr 20, 8:49 pm, Roy Smith <[EMAIL PROTECTED]> wrote: > Hiding your source code is not easy (perhaps impossible) in Python, for > reasons which have been covered at length on a regular basis in this forum. > If you only ship .pyc or .pyo files, there is still enough information > recoverable in

Re: Nested lists, simple though

2008-04-20 Thread sturlamolden
On Apr 21, 12:25 am, Zethex <[EMAIL PROTECTED]> wrote: > Anyway the amount of [[]] do increase over time. Im just wondering is there > a simple way to add these together so they become 1 simple list, so it would > be ['computer''asus'] etc without the nested list. Its random the > amount eac

Re: Nested lists, simple though

2008-04-20 Thread sturlamolden
On Apr 21, 12:25 am, Zethex <[EMAIL PROTECTED]> wrote: > Anyway the amount of [[]] do increase over time. You can flatten a nested list using a closure and recursion: def flatten(lst): tmp = [] def _flatten(lst): for elem in lst: if type(elem) != list:

Re: Nested lists, simple though

2008-04-20 Thread sturlamolden
On Apr 21, 2:35 am, sturlamolden <[EMAIL PROTECTED]> wrote: > This also shows how easy it is to boost the performance of Python code > using Cython. We can improve this further by getting rid of the tmp.append attribue lookup: cdef _flatten(lst, append): for elem in lst:

Re: "Help needed - I don't understand how Python manages memory"

2008-04-21 Thread sturlamolden
On Apr 21, 4:09 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > I'm not sure if this will help the OP at all - going into a world of dangling > pointers, keeping track of ownership, releasing memory by hand... One of the > good things of Python is automatic memory management. Ensuring that

Re: Segfault accessing dictionary in C Python module

2008-04-21 Thread sturlamolden
On Apr 22, 2:00 am, Mitko Haralanov <[EMAIL PROTECTED]> wrote: > As far as I know, I have done everything by the book yet I can't seem > to figure out where the problem is. Any help would be great? Albeit not having looked at your code in detail, I'm wiling to bet you have one of the refcounts wr

Re: subprocess module is sorely deficient?

2008-04-22 Thread sturlamolden
On Apr 22, 12:52 pm, Harishankar <[EMAIL PROTECTED]> wrote: > Sorry to start off on a negative note in the list, but I feel that the Python > subprocess module is sorely deficient because it lacks a mechanism to Have you looked at the processing module in cheese shop? -- http://mail.python.org/m

Re: Where to get BeautifulSoup--www.crummy.com appears to be down.

2008-04-23 Thread sturlamolden
On Apr 22, 8:36 pm, Kenneth McDonald <[EMAIL PROTECTED]> wrote: > Sadly. I can easily access: http://www.crummy.com/software/BeautifulSoup/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Psyco alternative

2008-04-24 Thread sturlamolden
On Mar 27, 4:44 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > PyPy is self-hosted and has been for some time (a year or so?). This is technically not correct. PyPy is hosted by RPython, which is not Python but a different language all together. -- http://mail.python.org/mailman/listi

Re: Psyco alternative

2008-04-24 Thread sturlamolden
On Mar 27, 4:02 pm, king kikapu <[EMAIL PROTECTED]> wrote: > As for psyco, are there any alternatives to use now ? When Cython has implemented all of Python's syntax, we can replace CPython's compiler and bytecode interpreter with Cython and a C compiler. Cython can be one or two orders of magni

Re: Psyco alternative

2008-04-24 Thread sturlamolden
On Mar 27, 5:01 pm, king kikapu <[EMAIL PROTECTED]> wrote: > Hmmm...thanks but i think Pyrex-like solution is not the ideal one. > Coming from C# and having 8 years of expertise on it, i have gain a > very positive thinking about jit compilers and i think that psyco (ok, > a just-in-time specializ

Re: Psyco alternative

2008-04-24 Thread sturlamolden
On Mar 27, 5:01 pm, king kikapu <[EMAIL PROTECTED]> wrote: > Hmmm...thanks but i think Pyrex-like solution is not the ideal one. > Coming from C# and having 8 years of expertise on it, i have gain a > very positive thinking about jit compilers and i think that psyco (ok, > a just-in-time specializ

Re: Psyco alternative

2008-04-24 Thread sturlamolden
On Apr 25, 2:15 am, Steve Holden <[EMAIL PROTECTED]> wrote: > I believe, without the benefit of recent experience, that the R stands > for Restricted. Thus and RPython program must of necessity also be a > valid Python program. Or do you know something I don't? That is correct. But RPython is not

Re: Psyco alternative

2008-04-24 Thread sturlamolden
On Mar 28, 8:06 pm, Paul Boddie <[EMAIL PROTECTED]> wrote: > From what I've seen from browsing publicly accessible materials, > there's a certain commercial interest in seeing Psyco updated > somewhat. YouTube uses Psyco. -- http://mail.python.org/mailman/listinfo/python-list

Re: Psyco alternative

2008-04-24 Thread sturlamolden
On Apr 25, 3:27 am, Steve Holden <[EMAIL PROTECTED]> wrote: > That seems a little harsh: it's Python-in-a-strait-jacket. > > The fact remains that since RPython programs also run under the standard > interpreter (albeit a factor of maybe a hundred times more slowly) their > claim of self-hosting i

Re: Remove multiple inheritance in Python 3000

2008-04-24 Thread sturlamolden
On Apr 22, 1:07 pm, GD <[EMAIL PROTECTED]> wrote: > Please remove ability to multiple inheritance in Python 3000. Too late for that, PEPs are closed. > Multiple inheritance is bad for design, rarely used and contains many > problems for usual users. > > Every program can be designed only with si

Re: Calling Python code from inside php

2008-04-24 Thread sturlamolden
On Apr 24, 5:51 am, Nick Stinemates <[EMAIL PROTECTED]> wrote: > I don't understand how the 2 are mutually exclusive? > > You can have PHP and Python bindings installed on the same Apache > server, unless I'm mistaken? Not everyone have the luxury of having mod_python installed. It depends on the

Re: Psyco alternative

2008-04-24 Thread sturlamolden
On Apr 25, 4:57 am, Steve Holden <[EMAIL PROTECTED]> wrote: > I am simply pointing out that RPython is used for efficiency, not to do > things that can't be done in standard Python. Yes. And if we only use a very small subset of Python, it would in effect be a form of assembly code. Hence my comm

Re: ctypes: return a pointer to a struct

2008-04-24 Thread sturlamolden
On Apr 25, 5:09 am, "Jack" <[EMAIL PROTECTED]> wrote: > typedef struct > { > char *country_short; > char *country_long; > char *region; > char *city; > char *isp; > float latitude; > float longitude; > char *domain; > char *zipcode; > char *timezone; > char *netspeed; > > } IP2LocationR

Re: ctypes: return a pointer to a struct

2008-04-24 Thread sturlamolden
On Apr 25, 5:15 am, sturlamolden <[EMAIL PROTECTED]> wrote: > First define a struct type IP2LocationRecord by subclassing from > ctypes.Structure. Then define a pointer type as > ctypes.POINTER(IP2LocationRecord) and set that as the function's > restype attribute. See

Re: ctypes: return a pointer to a struct

2008-04-24 Thread sturlamolden
On Apr 25, 5:39 am, "Jack" <[EMAIL PROTECTED]> wrote: > AttributeError: 'LP_IP2LocationRecord' object has no attribute > 'country_short' As it says, LP_IP2LocationRecord has no attribute called 'country_short'. IP2LocationRecord does. Use the 'contents' attribute to dereference the pointer. That

Re: ctypes: return a pointer to a struct

2008-04-24 Thread sturlamolden
On Apr 25, 5:39 am, "Jack" <[EMAIL PROTECTED]> wrote: > IP2Location_get_all.restype = POINTER(IP2LocationRecord) > IP2LocationObj = IP2Location_open(thisdir + '/IP-COUNTRY-SAMPLE.BIN') > rec = IP2Location_get_all(IP2LocationObj, '64.233.167.99') > print rec.country_short print rec.contents.countr

Re: Remove multiple inheritance in Python 3000

2008-04-25 Thread sturlamolden
On Apr 25, 2:03 pm, Bjoern Schliessmann wrote: > > That's how the Java designers were thinking as well: If MI is > > allowed, programmers will suddenly get an irresistible urge to use > > MI to write unmaintainable spaghetti code. So let's disallow MI > > for the sake of common good. > > Argument

Re: why does the following with Queue, q.put('\x02', True) not put it in the queue?

2008-04-25 Thread sturlamolden
On Apr 25, 4:38 pm, Gabriel Rossetti <[EMAIL PROTECTED]> wrote: > Hello, > > I'm having some trouble with the Queue class, for some reason, if I do > this (ch == ) : > > q = Queue.Queue(0) > repr(ch) > q.put(ch, True) > len(q.queue) >>> from Queue import Queue >>> q = Queue(0) >>> s = '\x02' >>>

Re: Calling Python code from inside php

2008-04-25 Thread sturlamolden
On Apr 23, 9:13 pm, [EMAIL PROTECTED] wrote: > A simple yet dangerous and rather rubbish solution (possibly more of a > hack than a real implementation) could be achieved by using a > technique described above: > > echo exec('python foo.py'); This will spawn a Python interpreter, and not

Re: Calling Python code from inside php

2008-04-25 Thread sturlamolden
On Apr 23, 9:08 pm, MC <[EMAIL PROTECTED]> wrote: > If you are under Windows, you can: > - call Python's functions via Active-Scripting > - call a Python COM server (functions or properties) > > For that, use Pywin32. And, in all cases, call functions can use > parameters. This is perhaps the p

Re: Python 2.6 and wrapping C libraries on Windows

2008-04-30 Thread sturlamolden
On Apr 30, 8:06 pm, "L. Lindstrom" <[EMAIL PROTECTED]> wrote: > I have read that Python extension modules must link to the same C > run-time as the Python interpreter. This I can appreciate. But does this > requirement extend to the C libraries an extension module wraps. This somewhat of a miscon

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread sturlamolden
On May 3, 10:13 pm, hdante <[EMAIL PROTECTED]> wrote: > I believe that moving this to third party could be better. What about > numpy ? Doesn't it already have something similar ? Yes, Kahan summation makes sence for numpy arrays. But the problem with this algorithm is optimizing compilers. The

Re: Multicore-programming?

2008-09-06 Thread sturlamolden
On 7 Sep, 00:06, cnb <[EMAIL PROTECTED]> wrote: > If I buy a multicore computer and I have really intensive program. How > would that be distributed across the cores? Distribution of processes and threads across processors (cores or CPUs) is managed by the operating system. > Will algorithms al

Re: Multicore-programming?

2008-09-06 Thread sturlamolden
On 7 Sep, 06:24, sturlamolden <[EMAIL PROTECTED]> wrote: > - Psyco, a Python JIT compiler, will often speed up algorithmic code. > Using psyco require to change to your code. Typo. It should say "Using psyco does not require you to change your code." -- http://mail.pytho

Re: Coming from .NET and VB and C

2008-09-08 Thread sturlamolden
On 3 Sep, 18:52, ToPostMustJoinGroup22 <[EMAIL PROTECTED]> wrote: > I'm coming from a .NET, VB, C background. > Any suggestions for someone new to the scene like me? Welcome! Unfortunately, you probably have a lot of bad habits to unlearn. Don't use Python like another C, VB or Java. It will ca

Re: NumPy arrays that use memory allocated from other libraries or tools

2008-09-10 Thread sturlamolden
On Sep 10, 6:39 am, Travis Oliphant <[EMAIL PROTECTED]> wrote: > I wanted to point anybody interested to a blog post that describes a > useful pattern for having a NumPy array that points to the memory > created by a different memory manager than the standard one used by > NumPy. Here is somethi

Re: Python a good choice for experimenting with Win32 API?

2008-09-12 Thread sturlamolden
> (1) Would CPython be a good choice for this? How about iron python? How > about Jython (probably not). You can use CPython without any problems. Alternatives are pywin32, ctypes, cython, pyrex, Python C API. You can use .NET platform invoke from IronPython. You can use JNI from Jython, or an

Re: GUI programming with python

2008-09-12 Thread sturlamolden
On Sep 12, 8:33 pm, [EMAIL PROTECTED] (Al Dykes) wrote: > OK, what are my choices for an IDE/GUI development tool that runs on XP? That depends on the GUI toolkit you are using. My suggestion: CPython with wxPython: wxFormBuilder Cpython with PyQt: BlackAdder CPython with PyGTK: GLADE 3 Jytho

Python is slow?

2008-09-23 Thread sturlamolden
I have recently been playing with a kd-tree for solving the "post office problem" in a 12-dimensional space. This is pure cpu bound number crunching, a task for which I suspected Python to be inefficient. My prototype in Python 2.5 using NumPy required 0.41 seconds to construct the tree from 50,00

Re: Why no tailcall-optimization?

2008-09-23 Thread sturlamolden
On Sep 23, 3:13 am, process <[EMAIL PROTECTED]> wrote: > Why doesn't Python optimize tailcalls? Are there plans for it? Because Python is a dynamic language. While a function is executing, its name may be bound to another object. It may happen as a side effect of what the function is doing, or ev

Re: Python is slow?

2008-09-23 Thread sturlamolden
On Sep 23, 3:44 pm, Robert Singer <[EMAIL PROTECTED]> wrote: > Well, python is not a number crunching language. However much we would > like it to be (we would ? :-). > No scripting language is. Not even Matlab, R, IDL, Octave, SciLab, S-PLUS or Mathematica? > Before resorting to rewriting the

Re: Python is slow?

2008-09-23 Thread sturlamolden
On Sep 23, 5:31 pm, [EMAIL PROTECTED] wrote: > Well written C++ code is generally faster or much faster than similar > Python code, but programming in Python is often simpler, and it > generally requires less time. So it may happen that to solve a problem > a Python program that runs in 1 hour tha

Re: Linq to Python

2008-09-23 Thread sturlamolden
On Sep 23, 4:48 pm, hrishy <[EMAIL PROTECTED]> wrote: > Will LINQ be ported to Python ? No, because Python already has list comprehensions and we don't need the XML buzzword. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is slow?

2008-09-23 Thread sturlamolden
On Sep 23, 8:52 pm, [EMAIL PROTECTED] wrote: > I think the Python version suffices. If it's not too much private you > may post the single minimal/reduced runnable Python module here, it > will be deleted in some time (if you want you can also use a private > paste):http://codepad.org/ http://cod

Re: Python is slow?

2008-09-23 Thread sturlamolden
On Sep 23, 9:17 pm, Robert Kern <[EMAIL PROTECTED]> wrote: > You could also drop it on the scipy.org wiki in the Cookbook category. Yes, if I could figure out how to use it... -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is slow?

2008-09-23 Thread sturlamolden
On Sep 23, 10:05 pm, Robert Singer <[EMAIL PROTECTED]> wrote: > May I ask what are your main objections to it ? 1. gfortran is not Absoft. 2. If I program the same in C99 and Fortran 95, and compile with gcc and gfortran, the C99 code runs a lot faster (I've only tested with wavelet transforms).

Re: Python is slow?

2008-09-23 Thread sturlamolden
On Sep 23, 10:16 pm, Robert Kern <[EMAIL PROTECTED]> wrote: > What's confusing? You do have to create a profile: How do I add a new page to the wiki? I'm only able to edit the front page of the cookbook. But it doesn't help to add link there if I have no page to link. (I may be incredibly stupid

Re: Python is slow?

2008-09-23 Thread sturlamolden
On Sep 23, 8:52 pm, [EMAIL PROTECTED] wrote: > Is this a good or bad thing? ;-) It seems we have been implementing different algorithms. kd-trees are not BK-trees. http://www.scipy.org/Cookbook/KDTree -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is slow?

2008-09-24 Thread sturlamolden
For those who are interested: I've updated the cookbook tutorial on the kd-tree: http://scipy.org/Cookbook/KDTree It now also includes parallel search for multicore CPUs (multiprocessing standard module). Even if you are not genuinely interested in kd-trees, it shows how to do parallel processi

Re: Python is slow?

2008-09-24 Thread sturlamolden
I have updated the cookbook entry for yesterday to also include parallel processing for large data sets. Even if you're not interested in kd-trees, it is a good example of what the new multiprocessing standard module can do. There are still people being scared by the GIL, thinking it prevents Pyth

<    1   2   3   4   5   6   7   8   >