Re: xmlrpc idea for getting around the GIL

2009-11-24 Thread sturlamolden
On 24 Nov, 16:13, Antoine Pitrou wrote: > >> Has anyone every tried wrapping the CPython lib into a daemon with an > >> RPC mechanism in order to move the GIL out of the process? > > >> I imagine this is how the multiprocessing module works. > > > It does not. > > Actually, it is how multiprocess

Re: Python critique

2011-01-31 Thread sturlamolden
On 10 Des 2010, 21:02, John Nagle wrote: >     Probably the biggest practical problem with CPython is > that C modules have to be closely matched to the version of > CPython.  There's no well-defined API that doesn't change. ctypes and DLLs in plain C do not change, and do not depend on CPython

Re: Python critique

2011-01-31 Thread sturlamolden
On 11 Des 2010, 00:09, Antoine Pitrou wrote: > >     Probably the biggest practical problem with CPython is > > that C modules have to be closely matched to the version of > > CPython.  There's no well-defined API that doesn't change. > > Please stop spreading FUD:http://docs.python.org/c-api/ind

Re: WxPython versus Tkinter.

2011-01-31 Thread sturlamolden
On 23 Jan, 01:07, rantingrick wrote: > It is time to prove once and for all how dated and worthless Tkinter > is compared to wxPython. Yes, WxPython is not as advanced as i would > like it to be for a 21st century GUI library. So use PyQt instead. > However compared to > Tkinter, Wx is light ye

Re: Perl Hacker, Python Initiate

2011-02-03 Thread sturlamolden
On 2 Feb, 05:36, Gary Chambers wrote: > Given the following Perl script: (...) Let me quote the deceased Norwegian lisp hacker Erik Naggum: "Excuse me while I barf in Larry Wall's general direction." Sturla -- http://mail.python.org/mailman/listinfo/python-list

Re: Idea for removing the GIL...

2011-02-08 Thread sturlamolden
On 8 Feb, 10:39, Vishal wrote: > Is it possible that the Python process, creates copies of the > interpreter for each thread that is launched, and some how the thread > is bound to its own interpreter ? In .NET lingo this is called an 'AppDomain'. This is also how tcl works -- one interpreter p

Re: EPD 7.0 released

2011-02-13 Thread sturlamolden
EPD is great, at least for scientific users. There is just one installer, with everything we need, instead of struggling with dozens of libraries to download, configure and build. It is still Python 2.7 (not 3.1) due to libraries like SciPy. A subscription for EPD is also a contribution to the deve

Re: EPD 7.0 released

2011-02-14 Thread sturlamolden
On 14 Feb, 01:50, Robert Kern wrote: > I'd just like to jump in here to clear up this last statement as an Enthought > employee. While Enthought and its employees do contribute to the development > of > numpy and scipy in various ways (and paying us money is a great way to let us > do > more of

Re: EPD 7.0 released

2011-02-14 Thread sturlamolden
On 14 Feb, 13:35, "Colin J. Williams" wrote: > The purchase price for what, until now, has been open source and free > seems high. The price is not high compared to other tools scientists are using, e.g. Matlab and S-PLUS. If you consider to buy an MKL license from Intel only to build NumPy and

Re: Non-linear regression help in Python

2011-02-14 Thread sturlamolden
On 14 Feb, 22:02, Akand Islam wrote: > Hello all, > I want to do non-linear regression by fitting the model (let say, y = > a1*x+b1*x**2+c1*x**3/exp(d1*x**4)) where the parameter (say "c1") must > be in between (0 to 1), and others can be of any values. How can I > perform my job in python? First

Re: Non-linear regression help in Python

2011-02-15 Thread sturlamolden
On 15 Feb, 05:24, Akand Islam wrote: > Dear Sturlamolden, > Thanks for reply. I will follow-up if I need further assistance. > > -- Akand You should rather use the SciPy user mailing list than comp.lang.python for this. Sturla -- http://mail.python.org/mailman/listinfo/python-list

Re: logging module -- better timestamp accuracy on Windows

2011-02-16 Thread sturlamolden
On 16 Feb, 15:30, benhoyt wrote: > It seems to me that the logging module should use a millisecond-accurate > timestamp (time.clock) on Windows, just like the "timeit" module does. AFAIK, the Windows performance counter has long-term accuracy issues, so neither is perfect. Preferably we should

Re: Python fails on math

2011-02-22 Thread sturlamolden
On 22 Feb, 14:20, christian schulze wrote: > Hey guys, > > I just found out, how much Python fails on simple math. I checked a > simple equation for a friend. Python does not fail. Floating point arithmetics and numerical approximations will do this. If you need symbolic maths, consider using the

Re: where are the program that are written in python?

2010-05-21 Thread sturlamolden
On 21 Mai, 12:21, Deep_Feelings wrote: > 1- where are the programs that is written in python ? You could search for them with Google and download your results Bittorrent. > is python a valid practical programming language ? No, it is probably Turing incomplete. -- http://mail.python.org/mai

Re: Another "Go is Python-like" article.

2010-05-21 Thread sturlamolden
On 21 Mai, 16:20, Grant Edwards wrote: > I still don't get it. > > What about Go, exactly, do people see as Phython-like? > > Go doesn't seem to have any of the salient features (either syntactic > or semantic) of Python other than garbage collection. > > How is Go not just warmed-over Java? Go

Re: where are the program that are written in python?

2010-05-22 Thread sturlamolden
On 21 Mai, 20:20, Patrick Maupin wrote: > There are a lot of commercial programs written in Python.  But any > company which thinks it has a lock on some kind of super secret sauce > isn't going to use Python, because it's very easy to reverse engineer > even compiled Python programs. Decompilin

Re: getting local area connection information through python in windows

2010-05-22 Thread sturlamolden
On 22 Mai, 09:38, moijes12 wrote: > I need to get the details of Local Area connection information(network > interface) like packets sent,packets recieved,duration etc. I have to > do this in Windows using python. >>> import subprocess as sp >>> p = sp.Popen("netstat -s", shell=False, bufsize=

Re: where are the program that are written in python?

2010-05-22 Thread sturlamolden
On 22 Mai, 17:09, a...@pythoncraft.com (Aahz) wrote: > Rewriting an algorithm also helps I/O-bound code Yes it does, if it involves how we do I/O. Algorithms are just as important for I/O bound as they are for compute bound code. But implementing an algorithm in C as opposed to Python would not

Re: where are the program that are written in python?

2010-05-22 Thread sturlamolden
On 22 Mai, 20:45, Patrick Maupin wrote: > I think we're in violent agreement here -- you neglected to quote the > part where I said "(But the up-front choice of another language simply > for speed, rather than prototyping with Python and then recoding the > slow bits, would probably be a decision

Re: where are the program that are written in python?

2010-05-22 Thread sturlamolden
On 22 Mai, 13:28, Tim Chase wrote: > Just as an aside, last I checked, mercurial had some core code in > C for speed.   I've been writing scrintific software for over 10 years. I always find myself writing small pieces of C now and then. It is usally because header files are too complicated to e

Re: where are the program that are written in python?

2010-05-23 Thread sturlamolden
On 23 Mai, 10:47, David Cournapeau wrote: > I would rather say that Python vs C does not matter until it does, I disagree. C matters because it is portable assembly code. Which means it is tedious and error prone to use, so avoiding it actually matters. Hence C matters. Knowing when and when not

Re: Lockless algorithms in python (Nothing to do with GIL)

2010-06-28 Thread sturlamolden
> > Many lockless algorithms that I have looked at thusfar require a > > "Compare and Swap" operation. Does python have an equivalent to this? > > Is python high level enough that it has something better than this or > > it simply doesn't need it? Python does have a GIL, and contrary to the title

Re: Lockless algorithms in python (Nothing to do with GIL)

2010-06-28 Thread sturlamolden
> > Many lockless algorithms that I have looked at thusfar require a > > "Compare and Swap" operation. Does python have an equivalent to this? > > Is python high level enough that it has something better than this or > > it simply doesn't need it? Python does have a GIL, and contrary to the title

Re: Lockless algorithms in python (Nothing to do with GIL)

2010-06-28 Thread sturlamolden
On 29 Jun, 05:11, Ryan Kelly wrote: > Very interesting idea.  Will it work if accessed through ctypes? > >    ticker = ctypes.c_int.in_dll(ctypes.pythonapi,"_Py_Ticker") >    ticker.value = 0x7fff > > Or does ctypes muck with the GIL in a way that would break this idea? > >>> ctypes.pythonap

Lua is faster than Fortran???

2010-07-03 Thread sturlamolden
I was just looking at Debian's benchmarks. It seems LuaJIT is now (on median) beating Intel Fortran! C (gcc) is running the benchmarks faster by less than a factor of two. Consider that Lua is a dynamically typed scripting language very similar to Python. LuaJIT also runs the benchmarks faster t

Re: Lua is faster than Fortran???

2010-07-03 Thread sturlamolden
On 4 Jul, 06:15, Steven D'Aprano wrote: > "Need" is a bit strong. There are plenty of applications where if your > code takes 0.1 millisecond to run instead of 0.001, you won't even > notice. Or applications that are limited by the speed of I/O rather than > the CPU. > But I'm nitpicking... this

Re: Lua is faster than Fortran???

2010-07-04 Thread sturlamolden
On 4 Jul, 16:47, "bart.c" wrote: > I suspect also the Lua JIT compiler optimises some of the dynamicism out of > the language (where it can see, for example, that something is always going > to be a number, and Lua only has one numeric type with a fixed range), so > that must be a big help. Pyth

Re: Lua is faster than Fortran???

2010-07-04 Thread sturlamolden
On 4 Jul, 10:03, Stefan Behnel wrote: > Sort of. One of the major differences is the "number" type, which is (by > default) a floating point type - there is no other type for numbers. The > main reason why Python is slow for arithmetic computations is its integer > type (int in Py3, int/long in P

Re: Lua is faster than Fortran???

2010-07-04 Thread sturlamolden
On 4 Jul, 14:29, David Cournapeau wrote: > Actually, I think the main reason why Lua is much faster than other > dynamic languages is its size. The language is small. You don't list, > dict, tuples, etc... They have managed to combine list and dict into one type (table) that does the job of both

Re: Lua is faster than Fortran???

2010-07-04 Thread sturlamolden
On 4 Jul, 09:12, Rami Chowdhury wrote: > Out of curiosity, does anyone know how the Unladen Swallow version of Python > does by comparison? Judging from their PyCon slides, it's roughly 1.5 times faster than CPython. That might be important to Google, but not to me. -- http://mail.python.org

Re: Lua is faster than Fortran???

2010-07-04 Thread sturlamolden
On 4 Jul, 18:34, David Cournapeau wrote: > I sincerly doubt it - where do take the information that matlab use > float to represent int ? I've used Matlab since 1994, so I know it rather well... Only the recent versions can do arithmetics with number types different from double (or complex doub

Re: Lua is faster than Fortran???

2010-07-04 Thread sturlamolden
On 4 Jul, 19:02, Stefan Behnel wrote: > A number like "1.5 times faster" is meaningless without a specific > application and/or code section in mind. I'm pretty sure there are cases > where they are much faster than that, and there are cases where the net > gain is zero (or -0.x or whatever). He

Re: Lua is faster than Fortran???

2010-07-04 Thread sturlamolden
On 4 Jul, 19:51, Stefan Behnel wrote: > Ok, so, which of those do you care about? I have already said I don't care about unladen swallow. -- http://mail.python.org/mailman/listinfo/python-list

Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-04 Thread sturlamolden
On 2 Jul, 21:07, John Nagle wrote: > http://jens.mooseyard.com/2008/12/python-30-whats-the-point/ He is right on. The only thing Python 3k will do for me, is break all my code and be incompatible with all extension modules I need. "What's the point?" indeed. -- http://mail.python.org/mailman/

Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-04 Thread sturlamolden
On 5 Jul, 01:58, John Nagle wrote: >      Exactly. > >      The "incompatible with all extension modules I need" part > is the problem right now.  A good first step would be to > identify the top 5 or 10 modules that are blocking a move to > Python 3 by major projects with many users. The big da

Re: Python as a scripting language. Alternative to bash script?

2010-07-06 Thread sturlamolden
On 28 Jun, 19:39, Michael Torrie wrote: > In python I could simply take the output of "ps ax" and use python's > own, superior, cutting routines (using my module): > > (err, stdout, stderr) = runcmd.run( [ 'ps', 'ax' ] ) > for x in stdout.split('\n'): >     print x.strip().split()[0] Or you just

Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
Just a little reminder: Microsoft has withdrawn VS2008 in favor of VS2010. The express version is also unavailable for download. >:(( We can still get a VC++ 2008 compiler required to build extensions for the official Python 2.6 and 2.7 binary installers here (Windows 7 SDK for .NET 3.5 SP1): h

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 6 Jul, 18:00, "Alf P. Steinbach /Usenet" wrote: > There is no *technical* problem creating a compiler-independent C/C++ language > binding. I believe that Java's JNI works fine no matter what compiler you use, > although it's many many years since I've done JNI things. Similarly, Python > shou

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 6 Jul, 18:21, Thomas Jollans wrote: > mingw gcc should work for building C++ extensions if it also works for C > extensions. No, it uses an incompatible statically linked C++ runtime. We need to use msvcp90.dll with Python 2.6/2.7. > As for amd64 - I do not know if there is a mingw64 releas

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 6 Jul, 19:09, Thomas Jollans wrote: > Okay, you need to be careful with FILE*s. But malloc and free? You'd > normally only alloc & free something within the same module, using the > same functions (ie not mixing PyMem_Malloc and malloc), would you not? You have to be sure PyMem_Malloc is not

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 6 Jul, 19:11, Thomas Jollans wrote: > Python is written in C. How does the C++ runtime enter into it? The C and C++ runtimes interact (e.g. stdlib.h and ), malloc and new, etc. With g++ you have a C++ standard library compiled against msvcrt.dll, whereas Python is using msvcr90.dll. We can u

Re: Python GUI for C program [was: ]

2010-07-06 Thread sturlamolden
On 6 Jul, 13:45, Thomas Jollans wrote: > 1. Turn your C program into a library, and write a Python extension Note that using ctypes, Cython or Boost.Python is much less painful than using Python's C API directly. > It might, however, be best to simply write the GUI in C as well, which > would a

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 6 Jul, 19:52, Ed Keith wrote: > This seems odd to me, has anyone else had this problem? DVD? -- http://mail.python.org/mailman/listinfo/python-list

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 6 Jul, 19:46, "Martin P. Hellwig" wrote: > Public download that is, people like me who have a MSDN subscription can > still download old versions like Visual Studio 2005. That's nice to know, but I personally don't have an MSDN subscription. Many scientists don't have access to development to

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 6 Jul, 21:49, Christian Heimes wrote: > I agree, the situation isn't ideal. I see if I can get in contact with > Microsoft's open source team. Perhaps they can keep the download link to > VS 2008 EE working. It seems the MSDN subscription required to get VS 2008 costs one dollar less than $12

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 6 Jul, 21:52, casevh wrote: > On Jul 6, 9:21 am, Thomas Jollans wrote: > > But that doesn't really > > change anything: the express edition of Microsoft's VC++ doesn't include > > an amd64 compiler anyway, AFAIK. See here: http://jenshuebel.wordpress.com/2009/02/12/visual-c-2008-express-edit

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 6 Jul, 21:52, casevh wrote: > The original version of the Windows 7 SDK includes the command line > version of the VS 2008 amd64 compiler. I've used it compile MPIR and > GMPY successfully. The GMPY source includes a text file describing the > build process using the SDK tools. It should also

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 7 Jul, 00:41, sturlamolden wrote: > It should also be mentioned that the Windows 7 SDK includes > vcbuild.exe, so it can be used to compile Visual Studio 2008 projects > (I'm going to try Python). Not sure why I forgot to mention, but we can (or even should?) use CMake to

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 7 Jul, 01:07, Thomas Jollans wrote: > It's not managed code in the "runs on .net" sense, but in principle, it > is managed, in that garbage collection is managed for you. I think you are confusing Python and C code. -- http://mail.python.org/mailman/listinfo/python-list

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-07 Thread sturlamolden
On 7 Jul, 11:32, Jonathan Hartley wrote: > Also, > this would solve the pain of Python developers attempting to > redistribute py2exe versions of their programs (i.e. they have to own > a Visual Studio license to legally be able to redistribute the > required C runtime) http://www.microsoft.com/d

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-07 Thread sturlamolden
On 7 Jul, 06:54, "Alf P. Steinbach /Usenet" wrote: > PyAPI_FUNC(void *) PyMem_Malloc(size_t); > > #define PyMem_MALLOC(n)         (((n) < 0 || (n) > PY_SSIZE_T_MAX) ? NULL \ >                                 : malloc((n) ? (n) : 1)) I was afraid of that :( > Except for the problems with file

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-07 Thread sturlamolden
On 7 Jul, 21:12, sturlamolden wrote: > > #define PyMem_MALLOC(n)         (((n) < 0 || (n) > PY_SSIZE_T_MAX) ? NULL \ > >                                 : malloc((n) ? (n) : 1)) > > I was afraid of that :( Also observe that this macro is very badly written (even illega

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-07 Thread sturlamolden
On 7 Jul, 21:41, "Alf P. Steinbach /Usenet" wrote: > > You still have two CRTs linked into the same process. > > So? CRT resources cannot be shared across CRT borders. That is the problem. Multiple CRTs are not a problem if CRT resources are never shared. -- http://mail.python.org/mailman/l

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-07 Thread sturlamolden
On 7 Jul, 21:47, "Martin v. Loewis" wrote: > That would partially defeat the purpose, namely it would require the > compiler to put the size into a variable in memory, and possibly prevent > optimizations from taking place that rely on constant propagation > (depending on how smart the compiler i

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-07 Thread sturlamolden
On 7 Jul, 21:47, "Martin v. Loewis" wrote: > However, the C standard is silent wrt. to PyMem_MALLOC, and it certainly > allows the definition of macros which use the macro arguments more than > once. Ok, I knew there was something odd here. PyMem_Malloc is indeed a function, whilst PyMem_MALLOC

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-07 Thread sturlamolden
On 7 Jul, 22:26, Christian Heimes wrote: > Don't forget errno! Every CRT might have its own errno thread local. I > don't know how its handled on Windows but I suspect it suffers from the > same problem. The Windows API "errno" is GetLastError. But a delinquent CRT might map GetLastError() to ot

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-07 Thread sturlamolden
On 7 Jul, 23:33, "Martin v. Loewis" wrote: > > The Windows API "errno" is GetLastError. But a delinquent CRT might > > map GetLastError() to other integers. > > Please check the source before posting. msvcrt defines errno as I don't have the source to msvcrt, at least not to my knowledge. --

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-07 Thread sturlamolden
On 7 Jul, 23:19, "Alf P. Steinbach /Usenet" wrote: >    D Linking the CRT dynamically and providing an optional download and >      install of the redistributables if they're not present. This would >      best be done with some support from the Python installation machinery. >      -> Small nice

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-07 Thread sturlamolden
On 8 Jul, 00:35, Jonathan Hartley wrote: > I see. Thanks very much to both of you for the info, much appreciated. The problem you referred to for py2exe despaired with Python 2.6. For Python 2.5, there was no public download option for msvcr71.dll and msvcp71.dll. There was also the unsolved SxS

"is not" operator?

2010-07-08 Thread sturlamolden
What happens here? Does Python (2.6.5) have an "is not" operator? >>> a = 5 >>> print (a is not False) True >>> print (a is (not False)) False >>> print (not (a is False)) True It seems "y is not x" fits well with spoken English, but it is also a bit surprising that "y is not x" does not mean "y

Re: Lua is faster than Fortran???

2010-07-08 Thread sturlamolden
On 4 Jul, 21:59, Stefan Behnel wrote: > > I have already said I don't care about unladen swallow. > > What I meant, was: which of these benchmarks would have to be better to > make you care? Because your decision not to care seems to be based on > exactly these benchmarks. Those are the only one

Re: "is not" operator?

2010-07-08 Thread sturlamolden
On 8 Jul, 22:32, Robert Kern wrote: > > What happens here? Does Python (2.6.5) have an "is not" operator? > > Yes. From Grammar/Grammar: > > comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' Thanks :) -- http://mail.python.org/mailman/listinfo/python-list

Re: "is not" operator?

2010-07-08 Thread sturlamolden
On 8 Jul, 22:29, John Krukoff wrote: > Don't forget about the similar "not in", as in: I noticed that in the grammar Robert posted. It never occurred to me as being a special operator too, but it is. -- http://mail.python.org/mailman/listinfo/python-list

Re: Lua is faster than Fortran???

2010-07-08 Thread sturlamolden
On 9 Jul, 05:39, Felix wrote: > This is something that I have been thinking about recently. Python has > won quite a following in the scientific computing area, probably > especially because of great libraries such as numpy, scipy, pytables > etc. Python is much more friendly to memory than Matl

Re: Lua is faster than Fortran???

2010-07-08 Thread sturlamolden
On 9 Jul, 06:44, Stefan Behnel wrote: > WRT a single machine, you should note that GPGPUs are a lot faster these > days than even multi-core CPUs. And Python has pretty good support for > GPUs, too. With OpenCL, Python is better than C for heavy computing. The Python or C/C++ program has to supp

Re: Lua is faster than Fortran???

2010-07-09 Thread sturlamolden
On 9 Jul, 15:25, Felix wrote: > PS: No need to convince me that MATLAB is not the solution. What I mean is that Matlab and Mathematica are inherently "single threaded" interpreters. Yet they are still used for serious parallel computing. While Python has multiple threads but a GIL, only allowing

Re: any issues with long running python apps?

2010-07-10 Thread sturlamolden
On 10 Jul, 02:23, Tim Chase wrote: > While I'm not sure how much of Roy's comment was "hah, hah, just > serious", this has been my biggest issue with long-running Python > processes on Win32 -- either power outages the UPS can't handle, > or (more frequently) the updates Win32 is also the only O

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-10 Thread sturlamolden
On 9 Jul, 02:02, Neil Hodgson wrote: >    If you break the rules by using malloc rather than IMalloc for memory > that is deallocated by a different component to that which allocated it > or try to pass around FILE* objects then you will see failures. Yes, the CRT issue applies to COM as well. C

Re: Easy questions from a python beginner

2010-07-11 Thread sturlamolden
On 11 Jul, 21:37, "Alf P. Steinbach /Usenet" wrote: > Oh, I wouldn't give that advice. It's meaningless mumbo-jumbo. Python works > like > Java in this respect, that's all; neither Java nor Python support 'swap'. x,y = y,x -- http://mail.python.org/mailman/listinfo/python-list

Re: Easy questions from a python beginner

2010-07-12 Thread sturlamolden
On 12 Jul, 07:51, "Alf P. Steinbach /Usenet" wrote: > We're talking about defining a 'swap' routine that works on variables. I did not miss the point. One cannot make a swap function that rebinds its arguments in the calling stack frame. But a swap function can swap values, given that the type i

Re: Cpp + Python: static data dynamic initialization in *nix shared lib?

2010-07-13 Thread sturlamolden
On 9 Jul, 17:52, "Alf P. Steinbach /Usenet" wrote: > For an extension module it seems that Python requires each routine to be > defined > as 'extern "C"'. That is strange. PyMethodDef is just a jump table. So why should 'extern "C"' matter? Good luck on re-inventing the wheel (you've probably

Re: Cpp + Python: static data dynamic initialization in *nix shared lib?

2010-07-13 Thread sturlamolden
On 13 Jul, 21:39, "Alf P. Steinbach /Usenet" wrote: > Thanks! It seems that SCXX does those things that I've been planning to do but > haven't got around to (wrapping standard Python types), while what it doesn't > do > (abstracting away all those tables etc. and mapping Python calls to C++ call

Re: Cpp + Python: static data dynamic initialization in *nix shared lib?

2010-07-13 Thread sturlamolden
On 13 Jul, 22:35, "Alf P. Steinbach /Usenet" wrote: > In practice, 'extern "C"' matters for the jump tables because for those few > compilers if any where it really matters (not just the compiler emitting a > warning like reportedly Sun CC does), different linkage can imply different > machine co

Re: Cpp + Python: static data dynamic initialization in *nix shared lib?

2010-07-13 Thread sturlamolden
On 13 Jul, 22:35, "Alf P. Steinbach /Usenet" wrote: > Yes, I know Boost.Python in more detail and I've heard of all the rest except > SIP, In my opinion, SIP is the easiest way of integrating C++ and Python. Just ignore the PyQt stuff. http://www.riverbankcomputing.co.uk/static/Docs/sip4/using

Re: Struqtural: High level database interface library

2010-07-17 Thread sturlamolden
On 17 Jul, 07:29, Nathan Rice wrote: > Let’s push things to the edge now with a quick demo of many to many > relationship support. For this example we’re going to be using the > following XML: > > >     >         123 >         Sales >         >             143 >             Raul Lopez >      

Re: Sharing: member type deduction for member pointers (Alf's device?)

2010-07-17 Thread sturlamolden
On 17 Jul, 15:02, "Alf P. Steinbach /Usenet" wrote: > #include      // PyWeakPtr, PyPtr, PyModule, PyClass > using namespace progrock; > > namespace { >      using namespace cppy; > >      struct Noddy >      { >          PyPtr       first; >          PyPtr       last; >          int         num

Re: why is this group being spammed?

2010-07-18 Thread sturlamolden
On 18 Jul, 07:01, "be.krul" wrote: > why is this group being spammed? There used to be bots that issued cancel messages against spam, but I don't think they are actively maintained anymore. -- http://mail.python.org/mailman/listinfo/python-list

Re: Exposing buffer interface for non-extension types?

2010-07-20 Thread sturlamolden
On 21 Jul, 02:38, Ken Watford wrote: > Perhaps, but *why* is it only a pure C-level interface? It is exposed to Python as memoryview. If memoryview is not sufficient, we can use ctypes.pythonapi to read the C struct. -- http://mail.python.org/mailman/listinfo/python-list

Re: Accumulate function in python

2010-07-27 Thread sturlamolden
On 19 Jul, 13:18, dhruvbird wrote: > Hello, >   I have a list of integers: x = [ 0, 1, 2, 1, 1, 0, 0, 2, 3 ] >   And would like to compute the cumulative sum of all the integers > from index zero into another array. So for the array above, I should > get: [ 0, 1, 3, 4, 5, 5, 5, 7, 10 ] >   What is

Re: Performance ordered dictionary vs normal dictionary

2010-07-28 Thread sturlamolden
On 29 Jul, 03:47, Navkirat Singh wrote: > I was wondering what would be better to do some medium to heavy book keeping > in memory - Ordered Dictionary or a plain simple Dictionary object?? It depends on the problem. A dictionary is a hash table. An ordered dictionary is a binary search tree (B

Re: Why is python not written in C++ ?

2010-08-02 Thread sturlamolden
On 2 Aug, 01:08, candide wrote: > Has it ever been planned to rewrite in C++ the historical implementation > (of course in an object oriented design) ? OO programming is possible in C. Just take a look at GNOME and GTK. Perl is written in C++. That is not enough to make me want to use it ;) T

Re: Why is python not written in C++ ?

2010-08-02 Thread sturlamolden
On 2 Aug, 05:04, Tomasz Rola wrote: > And one should not forget about performance. C++ was for a long time > behind C, and even now some parts (like iostreams) should be avoided in > fast code. For fast I/O one must use platform specific APIs, such as Windows' i/o completion ports and memory map

Re: Why is python not written in C++ ?

2010-08-02 Thread sturlamolden
On 3 Aug, 00:27, Paul Rubin wrote: > Certain folks in the functional-programming community consider OO to be > a 1980's or 1990's approach that didn't work out, and that what it was > really trying to supply was polymorphism.  C++ programs these days > apparently tend to use template-based generi

Re: Why is python not written in C++ ?

2010-08-02 Thread sturlamolden
On 3 Aug, 01:14, Martin Gregorie wrote: > Bottom line: All this would still have happened regardless of the > programming language used. I am quite sure C and Fortran makes it unlikely for an unhandled exception to trigger the autodestruct sequence. But it's nice to know when flying that modern

Re: Why is python not written in C++ ?

2010-08-02 Thread sturlamolden
On 3 Aug, 01:37, Mark Lawrence wrote: > A bug is a bug is a bug? According to Grace Hopper, a bug might be a moth, in which case the best debugger is a pair of forceps. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is python not written in C++ ?

2010-08-02 Thread sturlamolden
On 3 Aug, 02:47, Roy Smith wrote: > This one I don't understand.  Yes, I get RAII, but surely there are > valid reasons to allocate memory outside of constructors.  Containers > which resize themselves (such as std::vector) are one obvious example. That is because an exception might skip an arbi

Re: Why is python not written in C++ ?

2010-08-02 Thread sturlamolden
On 3 Aug, 04:03, sturlamolden wrote: > struct File { >     std::FILE *fid; >     File(const char *name) { >         // acquire resource in constructor >         fid = std::fopen(name); >         if (!fid) throw some_exception; >     } >     ~File() { >         //

Re: Normalizing A Vector

2010-08-02 Thread sturlamolden
On 30 Jul, 13:46, Lawrence D'Oliveiro wrote: > Say a vector V is a tuple of 3 numbers, not all zero. You want to normalize > it (scale all components by the same factor) so its magnitude is 1. > > The usual way is something like this: > >     L = math.sqrt(V[0] * V[0] + V[1] * V[1] + V[2] * V[2])

Re: Why is python not written in C++ ?

2010-08-03 Thread sturlamolden
On 4 Aug, 04:41, Grant Edwards wrote: > The issue that would prevent its use where I work is the inability to > hire anybody who knows Ada.  You can't hire anybody who knows C++ > either, but you can hire lots of people who claim they do.   That is very true. -- http://mail.python.org/mailma

Re: Python -Vs- Ruby: A regexp match to the death!

2010-08-09 Thread sturlamolden
On 9 Aug, 10:21, Steven D'Aprano wrote: > And that it's quite finicky about blank lines between methods and inside > functions. Makes it hard to paste code directly into the interpreter. The combination of editor, debugger and interpreter is what I miss most from Matlab. In Matlab we can have a

Re: Why is python not written in C++ ?

2010-08-11 Thread sturlamolden
On 11 Aug, 08:40, Ulrich Eckhardt wrote: > That's true, maybe I don't remember the exact rationale. Especially if even > someone like you, who is much deeper into Python development, doesn't, I'm > wondering if I'm misremembering something Header (definition) and source (implementation) is n

Re: Help understanding the decisions *behind* python?

2009-08-01 Thread sturlamolden
On 20 Jul, 18:27, Phillip B Oldham wrote: > We're not looking to start any arguments or religious wars and we're > not asking that python be changed into something its not. We'd simply > like to understand the decision behind the lists and tuple structures. > We feel that in not "getting" the dif

Re: Help understanding the decisions *behind* python?

2009-08-01 Thread sturlamolden
On 31 Jul, 23:43, Raymond Hettinger wrote: > More than one person here has > observed that the time to learn to program Pythonically is inversely > proportional to their experience in Java. I believe it is opposite. The longer the Java experience, the longer it takes to program pythonically. The

Re: fast video encoding

2009-08-01 Thread sturlamolden
On 29 Jul, 10:14, gregorth wrote: > for a scientific application I need to save a video stream to disc for > further post processing. I have worked a bit on this as well. There are two things that make scientific applications different form common video encoding: First, a scientific video strea

Re: Does python have the capability for driver development ?

2009-08-01 Thread sturlamolden
On 30 Jul, 02:19, MalC0de wrote: > actually I mean driver programming under Windows operating system, if > you know, there's A kit name DDK available at microsoft's website for > developing device drivers under C / C++ environment, Actually, Microsoft has replaced DDK with a new kit called WDK f

Re: Help understanding the decisions *behind* python?

2009-08-01 Thread sturlamolden
On 2 Aug, 04:47, Nobody wrote: > OTOH, using a "for" loop when you could use a generator means less work > when you need to make a minor change and a generator is no longer > sufficient. It's not just that. It is e.g. using a for loop and indexes instead of a slice. E.g. for i in range(10): # J

Re: Help understanding the decisions *behind* python?

2009-08-01 Thread sturlamolden
On 31 Jul, 21:31, Masklinn wrote: > It's intuitive if you come to Python knowing other languages with   > tuples (which are mostly functional, and in which tuples are *never*   > sequences/iterables). At the end of the day, and if Guido's intention   > truly was what Raymond says, implementing tu

Re: Is python buffer overflow proof?

2009-08-03 Thread sturlamolden
On 2 Aug, 15:50, Jizzai wrote: > Is a _pure_ python program buffer overflow proof? > > For example in C++ you can declare a char[9] to hold user input. > If the user inputs 10+ chars a buffer overflow occurs. Short answer: NO Bounds checking on sequence types is a protection against buffer over

Re: Is python buffer overflow proof?

2009-08-04 Thread sturlamolden
On Aug 4, 2:27 pm, Tim Chase wrote: > You *can* shoot yourself in the foot with Python, you just have > to aim much more carefully than you do with C/C++. You can e.g. define a class with a __del__ method and make some circular references. That should give you a nice memory leak. -- http://mai

Re: Is this a bug in multiprocessing or in my script?

2009-08-04 Thread sturlamolden
On Aug 5, 4:37 am, erikcw wrote: > It's not always the same traceback, but they are always short like > this. I'm running Python 2.6.2 on Ubuntu 9.04. > > Any idea how I can debug this? In my experience, multiprocessing is fragile. Scripts tend fo fail for no obvious reason, case processes to b

<    2   3   4   5   6   7   8   >