Re: Python compiled modules are too big in size (even after strip)

2010-04-27 Thread Antoine Pitrou
Le Tue, 27 Apr 2010 02:43:19 -0700, King a écrit : > > Python is compiled and installed successfully. However the > modules(_socket.so, _random.so etc) are two big in terms of file size. > They are around 4.5-5.0 mb each. I have used "strip strip-all *.so", but > still size is around 1.5 mb each.

Re: chr(i) ASCII under Python 3

2010-04-27 Thread Antoine Pitrou
Le Mon, 26 Apr 2010 22:26:28 +0200, Alf P. Steinbach a écrit : > On 26.04.2010 22:12, * Dodo: >> Hi all, >> Under python 2.6, chr() "Return a string of one character whose ASCII >> code is the integer i." (quoted from docs.python.org) Under python 3.1, >> chr() "Return the string of one character w

Re: [Python3] Reading a binary file and wrtiting the bytes verbatim in an utf-8 file

2010-04-24 Thread Antoine Pitrou
Hello, > I have to read the contents of a binary file (a PNG file exactly), and > dump it into an RTF file. > > The RTF-file has been opened with codecs.open in utf-8 mode. You should use the built-in open() function. codecs.open() is outdated in Python 3. > As I expected, the utf-8 decoder c

Re: Python 2.6 SSL module: Fails on key file error, with Errno 336265225, without a key file.

2010-04-19 Thread Antoine Pitrou
Le Sun, 18 Apr 2010 22:37:30 -0700, John Nagle a écrit : > > The cert file is the same PEM file I use with M2Crypto, and it's derived > from Firefox's cert file. > > Why am I getting a "private key" related error? I'm not submitting a > keyfile, just a cert file. I'm not an expert but this is w

Re: universal newlines and utf-16

2010-04-11 Thread Antoine Pitrou
Le Sun, 11 Apr 2010 16:16:45 +0100, Baz Walter a écrit : > On 11/04/10 15:37, Stefan Behnel wrote: >> The codecs module does not support universal newline parsing (see the >> docs). You need to use the new io module instead. > > thanks. > > i'd completely overlooked the io module - i thought it w

Re: Unicode blues in Python3

2010-03-24 Thread Antoine Pitrou
Le Tue, 23 Mar 2010 10:33:33 -0700, nn a écrit : > I know that unicode is the way to go in Python 3.1, but it is getting in > my way right now in my Unix scripts. How do I write a chr(253) to a > file? > > #nntst2.py > import sys,codecs > mychar=chr(253) > print(sys.stdout.encoding) > print(mycha

Re: GC is very expensive: am I doing something wrong?

2010-03-23 Thread Antoine Pitrou
Le Tue, 23 Mar 2010 02:57:56 -0700, Paul Rubin a écrit : > > It is unlikely to happen by accident. You might care that it can happen > on purpose. See: http://www.cs.rice.edu/~scrosby/hash/ that I cited in > another post. The article shows some sample attacks on Python cgi's. Certainly interes

Re: GC is very expensive: am I doing something wrong?

2010-03-22 Thread Antoine Pitrou
Le Mon, 22 Mar 2010 23:40:16 +, tan a écrit : > >>Remember that the original use case was to load a dictionary from a text >>file. For this use case, a trie can be very wasteful in terms of memory >>and rather CPU cache unfriendly on traversal, whereas hash values are a) >>rather fast to calcu

Re: should writing Unicode files be so slow

2010-03-19 Thread Antoine Pitrou
Le Fri, 19 Mar 2010 17:18:17 +, djc a écrit : > > changing > with open(filename, 'rU') as tabfile: to > with codecs.open(filename, 'rU', 'utf-8', 'backslashreplace') as > tabfile: > > and > with open(outfile, 'wt') as out_part: to > with codecs.open(outfile, 'w', 'utf-8') as out_part: > > ca

Re: file seek is slow

2010-03-12 Thread Antoine Pitrou
Le Tue, 09 Mar 2010 15:56:47 -0800, Metalone a écrit : > for i in xrange(100): >f1.seek(0) This is quite a stupid benchmark to write, since repeatedly seeking to 0 is a no-op. I haven't re-read the file object code recently, but chances are that the Python file object has its own

Re: Asynchronous HTTP client

2010-03-12 Thread Antoine Pitrou
Le Sun, 07 Mar 2010 22:40:36 +0800, pingooo a écrit : > I'm writing an open source python client for a web service. The client > may be used in all kinds of environments - Linux, Mac OS X, Windows, web > hosting, etc by others. It is not impossible to have twisted as a > dependency, but that makes

Re: Please help with MemoryError

2010-02-12 Thread Antoine Pitrou
Le Fri, 12 Feb 2010 23:49:38 +0100, Alf P. Steinbach a écrit : > > The main reason for not using that term for Python is that "pass by > reference" has the extremely strong connotation of being able to > implement 'swap'. But 'swap' is so easy to write as a one-line statement that it's foolish t

Re: Please help with MemoryError

2010-02-12 Thread Antoine Pitrou
Le Fri, 12 Feb 2010 23:12:06 +0100, Alf P. Steinbach a écrit : > > Steven talks about the standard meaning of "pass by reference". See my answer to Steve's message. You can't postulate a "standard meaning" of "pass by reference" independently of the specificities of each language. For example a

Re: Please help with MemoryError

2010-02-12 Thread Antoine Pitrou
Le Fri, 12 Feb 2010 17:10:01 -0500, Steve Holden a écrit : > > As has already been pointed out, if Python used call by reference then > the following code would run without raising an AssertionError: > > def exchange(a, b): > a, b = b, a > > x = 1 > y = 2 > exchange(x, y) > assert (x == 2 an

Re: Please help with MemoryError

2010-02-12 Thread Antoine Pitrou
Le Fri, 12 Feb 2010 17:14:57 +, Steven D'Aprano a écrit : > > What Python does is called "pass by sharing", or sometimes "pass by > object reference". It is exactly the same as what (e.g.) Ruby and Java > do, except that confusingly the Ruby people call it "pass by reference" > and the Java pe

Re: Overcoming python performance penalty for multicore CPU

2010-02-08 Thread Antoine Pitrou
Le Tue, 02 Feb 2010 15:02:49 -0800, John Nagle a écrit : > I know there's a performance penalty for running Python on a multicore > CPU, but how bad is it? I've read the key paper > ("www.dabeaz.com/python/GIL.pdf"), of course. It would be adequate if > the GIL just limited Python to running on o

Re: TABS in the CPython C source code

2010-02-06 Thread Antoine Pitrou
Le Sat, 06 Feb 2010 22:26:55 +, Benjamin Peterson a écrit : > Neil Hodgson gmail.com> writes: >>This would damage the usefulness of source control histories (svn >> annotate) as all of the converted lines would show this recent cosmetic >> change rather than the previous change which is li

Re: recv_into(bytearray) complains about a "pinned buffer"

2010-02-02 Thread Antoine Pitrou
Le Tue, 02 Feb 2010 00:12:34 +0100, Martin v. Loewis a écrit : >> recv_into() should simply be fixed to use the new buffer API, as it >> does in 3.x. > > I don't think that's the full solution. The array module should also > implement the new buffer API, so that it would also fail with the old > r

Re: how long a Str can be used in this python code segment?

2010-02-01 Thread Antoine Pitrou
Le Mon, 01 Feb 2010 01:33:09 -0800, Stephen.Wu a écrit : > > actually, I just use file.read(length) way, i just want to know what > exactly para of length I should set, I'm afraid length doesn't equal to > the amount of physical memory after trials... There's no exact length you "should" set, jus

Re: recv_into(bytearray) complains about a "pinned buffer"

2010-02-01 Thread Antoine Pitrou
Le Mon, 01 Feb 2010 03:30:56 +0100, Martin v. Loewis a écrit : > >> Is this a bug in Python 2.6 or a deliberate choice regarding >> implementation concerns I don't know about? > > It's actually a bug also that you pass an array; doing so *should* give > the very same error. Well, if you can give

Re: recv_into(bytearray) complains about a "pinned buffer"

2010-01-31 Thread Antoine Pitrou
Hello Andrew, > I don't even know what a "pinned buffer" means, and searching python.org > isn't helpful. > > Using a bytearray in Python 3.1.1 *does* work: > [...] Agreed, the error message is cryptic. The problem is that socket.recv_into() in 2.6 doesn't recognize the new buffer API which is

Re: Some C-API functions clear the error indicator?

2010-01-30 Thread Antoine Pitrou
Le Fri, 29 Jan 2010 22:25:14 +0100, Austin Bingham a écrit : > Maybe I'm not following what you're saying. In my case, I already know > that an exception has been thrown. In the course of processing that > exception, I call another function which, for whatever reason and even > when it succeeds, cl

[OT] myths about python 3

2010-01-29 Thread Antoine Pitrou
Le Fri, 29 Jan 2010 13:16:11 +1100, Ben Finney a écrit : > > I think the reason “date” was initially used is because dates are most > familiar to us as fleshy, dark brown, wrinkled, compressed points. > > My interests in etymology and scatology unite here. Ah, I suppose it explains the strange A

Re: which one is faster?

2010-01-29 Thread Antoine Pitrou
Le Thu, 28 Jan 2010 22:39:32 -0800, alex23 a écrit : > On Jan 29, 4:29 pm, "Stephen.Wu" <54wut...@gmail.com> wrote: >> str.find(targetStr) >> str.index(targetStr) with exception >> str.count(targetStr) >> targetStr in str >> >> which is the fastest way to check whether targetStr is in str? > [...]

Re: myths about python 3

2010-01-28 Thread Antoine Pitrou
Le Wed, 27 Jan 2010 17:36:29 -0800, alex23 a écrit : > > I've been a big supporter of Py3 from the beginning, but this repeated > claim of US becoming the mainline interpreter for 3.x pretty much kills > dead a lot of my interest. As long as the U-S JIT can be disabled at compile-time (and also a

Re: myths about python 3

2010-01-28 Thread Antoine Pitrou
Le Thu, 28 Jan 2010 00:19:24 +, Steven D'Aprano a écrit : > 4. Python 3 will make you irresistible to women. > > FALSE - Python 3 coders are no more likely to get a date than any > other programmer. They spend less time coding, so they /can/ get more "dates" (what a strange English w

Re: Ad hoc lists vs ad hoc tuples

2010-01-27 Thread Antoine Pitrou
Le Wed, 27 Jan 2010 02:20:53 -0800, Floris Bruynooghe a écrit : > > Is a list or tuple better or more efficient in these situations? Tuples are faster to allocate (they are allocated in one single step) and quite a bit smaller too. In some situations, in Python 2.7 and 3.1, they can also be igno

Re: ctypes for AIX

2010-01-27 Thread Antoine Pitrou
Hello, > I then figured I would get a new copy of python and install it > on AIX. I downloaded python.2.5.5c2 from http://www.python.org. I did > the configure and make which posted many errors in the ctypes function > which I guess is the reason that is does not get include in the final > make.

Re: list.pop(0) vs. collections.dequeue

2010-01-25 Thread Antoine Pitrou
Le Sun, 24 Jan 2010 11:28:53 -0800, Aahz a écrit : > > Again, your responsibility is to provide a patch and a spectrum of > benchmarking tests to prove it. Then you would still have to deal with > the objection that extensions use the list internals -- that might be an > okay sell given the effor

Re: Generic Python Benchmark suite?

2010-01-19 Thread Antoine Pitrou
Le Mon, 18 Jan 2010 21:05:26 -0800, Anand Vaidya a écrit : > @Antoine, Terry, > > Thanks for the suggestions. > > I will investigate those. I just ran the pybench, doesn't run on 3.x, > 2to3 fails. You just have to use the pybench version that is bundled with 3.x (in the Tools directory). --

Re: python gui ide under linux..like visual studio ;) ?

2010-01-18 Thread Antoine Pitrou
Le Mon, 18 Jan 2010 15:32:36 +0100, ted a écrit : > > And, a good library for access to database (mysql, sql server, oracle) ? If you want something high-level: http://www.sqlalchemy.org/ You won't regret it :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Generic Python Benchmark suite?

2010-01-18 Thread Antoine Pitrou
Le Mon, 18 Jan 2010 01:58:42 -0800, Anand Vaidya a écrit : > Is there a generic python benchmark suite in active development? I am > looking forward to comparing some code on various python implementations > (primarily CPython 2.x, CPython 3.x, UnladenSwallow, Psyco). > > I am happy with something

Re: Generic Python Benchmark suite?

2010-01-18 Thread Antoine Pitrou
Le Mon, 18 Jan 2010 11:30:16 +0100, Stefan Behnel a écrit : > Anand Vaidya, 18.01.2010 10:58: >> Is there a generic python benchmark suite in active development? [...] >> PS: I think a benchmark should cover file / network, database I/O, >> data structures (dict, list etc), object creation/manipul

Re: Caching objects in a C extension

2010-01-08 Thread Antoine Pitrou
Le Fri, 08 Jan 2010 08:39:17 -0800, casevh a écrit : > > Thanks for the reply. I realized that I missed one detail. The objects > are created by the extension but are deleted by Python. I don't know > that an object is no longer needed until its tp_dealloc is called. At > that point, its reference

Re: please help shrink this each_with_index() implementation

2010-01-06 Thread Antoine Pitrou
Le Wed, 06 Jan 2010 12:12:08 -0800, Phlip a écrit : > > And I, not my language, should pick and chose how to be rigorous. The > language should not make the decision for me. And that's why there is the "try: ... except: ..." construct. Your rant is getting tiring. -- http://mail.python.org/mai

Re: Convert month name to month number faster

2010-01-06 Thread Antoine Pitrou
Le Wed, 06 Jan 2010 12:03:36 +0100, wiso a écrit : > from time import time > t = time(); xxx=map(to_dict,l); print time() - t # 0.5 t = time(); > xxx=map(to_if,l); print time() - t # 1.0 Don't define your own function just for attribute access. Instead just write: xxx = map(month_dict.__geti

Re: please help shrink this each_with_index() implementation

2010-01-05 Thread Antoine Pitrou
> The point: int('') or int('something') both throw an error. In general, > this is hand-holding, but in specific I don't think the "rich and > structured" documentation will cover how to beat a 0 out of it in less > than 3 lines. Because it's a bad idea to do so and Python doesn't encourage such

Re: please help shrink this each_with_index() implementation

2010-01-05 Thread Antoine Pitrou
>> Couldn't you just use the built-in enumerate() to replace the whole >> thing? > > Because that would involve, like, reading an entire Python book just to > locate that method? Actually, no. It just involves reading one of the most important pages in the documentation, the page which describ

Re: Speeding up network access: threading?

2010-01-05 Thread Antoine Pitrou
Le Tue, 05 Jan 2010 15:04:56 +0100, Jens Müller a écrit : > > Is a list thrad-safe or do I need to lock when adding the results of my > worker threads to a list? The order of the elements in the list does not > matter. The built-in list type is thread-safe, but is doesn't provide the waiting fea

Re: fsync() doesn't work as advertised?

2010-01-04 Thread Antoine Pitrou
Le Mon, 04 Jan 2010 08:09:56 -0800, Brian D a écrit : > > What I've seen is that flush() alone produces a complete log when the > loop finishes. When I used fsync(), I lost all of the write entries > except the first, along with odd error trap and the last entry. Perhaps you are writing to the fi

Re: multithreading, performance, again...

2009-12-31 Thread Antoine Pitrou
> 39123 function calls (38988 primitive calls) in 6.004 CPU > seconds > [...] > > It's not burning CPU time in the main thread (profiling with cProfile > indicated smth similar to the above), it's not burning it in the > individual worker threads What do you mean, it's not b

Re: detect interactivity

2009-12-30 Thread Antoine Pitrou
Le Wed, 30 Dec 2009 03:33:18 +0100, Roald de Vries a écrit : > > I'm using a database, and want to use python interactively to manipulate > it. On the other hand, I also want to be able to use it non- > interactively. In that case, it would be a waste of CPU to load the > function/class definition

Re: detect interactivity

2009-12-29 Thread Antoine Pitrou
Le Tue, 29 Dec 2009 16:09:58 +0100, Roald de Vries a écrit : > Dear all, > > Is it possible for a Python script to detect whether it is running > interactively? It can be useful for e.g. defining functions that are > only useful in interactive mode. Try the isatty() method (*) on e.g. stdin: $

Re: Recommendation for small, fast, Python based web server

2009-12-26 Thread Antoine Pitrou
Le Fri, 25 Dec 2009 10:38:19 -0800, Aahz a écrit : > In article , > Antoine Pitrou wrote: >> >>Apparently you have debugged your speed issue so I suppose you don't >>have performance problems anymore. Do note, however, that Python is >>generally not as fast as

Re: Semantic of operations on a closed file object

2009-12-26 Thread Antoine Pitrou
Hello, > But the io.IOBase.close() method document says: """Once the file is > closed, any operation on the file (e.g. reading or writing) will raise > an IOError .""" which unlike the > class doc is not conditional about the behavior... > > Experimentation (see below) show that I get a ValueErr

Re: Python3.1: gzip encoding with UTF-8 fails

2009-12-21 Thread Antoine Pitrou
Hello, Le Sun, 20 Dec 2009 17:08:33 +0100, Johannes Bauer a écrit : > > #!/usr/bin/python3 > import gzip > x = gzip.open("testdatei", "wb") > x.write("ä") The bug here is that you are trying to write an unicode text string ("ä") to a binary file (a gzip file). This bug has been fixed now; in th

Re: Where is PyMethod_GET_CLASS in Python 3?

2009-12-17 Thread Antoine Pitrou
Le Tue, 15 Dec 2009 08:08:01 -0800, Infinity77 a écrit : > > When building C extensions In Python 2.X, there was a magical > PyMethod_GET_CLASS implemented like this: > > #define PyMethod_GET_CLASS(meth) \ > (((PyMethodObject *)meth) -> im_class) > > It looks like Python 3 has wiped ou

Re: Dangerous behavior of list(generator)

2009-12-14 Thread Antoine Pitrou
Le Mon, 14 Dec 2009 15:21:09 +, exarkun a écrit : > > I'm asking about why the behavior of a StopIteration exception being > handled from the `expression` of a generator expression to mean "stop > the loop" is accepted by "the devs" as acceptable. It's not "accepted as acceptable", it's just

Re: Recommendation for small, fast, Python based web server

2009-12-11 Thread Antoine Pitrou
Le Fri, 11 Dec 2009 19:40:21 +0100, Irmen de Jong a écrit : > > I don't think that number is fair for Python. I think a well written > Python web server can perform in the same ballpark as most mainstream > web servers written in C. Especially Apache, which really isn't a top > performer. And I'm

Re: a huge shared read-only data in parallel accesses -- How? multithreading? multiprocessing?

2009-12-11 Thread Antoine Pitrou
Le Wed, 09 Dec 2009 06:58:11 -0800, Valery a écrit : > > I have a huge data structure that takes >50% of RAM. My goal is to have > many computational threads (or processes) that can have an efficient > read-access to the huge and complex data structure. > > "Efficient" in particular means "withou

Re: Recommendation for small, fast, Python based web server

2009-12-11 Thread Antoine Pitrou
Hello, > I've looked at the web servers that come bundled with the Python > standard library[1] and they are too slow. Apparently you have debugged your speed issue so I suppose you don't have performance problems anymore. Do note, however, that Python is generally not as fast as C -- especial

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Antoine Pitrou
Le Tue, 01 Dec 2009 06:03:36 -0800, Mark Summerfield a écrit : > I've produced a 4 page document that provides a very concise summary of > Python 2<->3 differences plus the most commonly used new Python 3 > features. It is aimed at existing Python 2 programmers who want to start > writing Python 3

Re: pointless musings on performance

2009-11-25 Thread Antoine Pitrou
Le Tue, 24 Nov 2009 16:09:10 -0800, Paul Boddie a écrit : > > I'm referring to what you're talking about at the end. The enhancements > in Python 3 presumably came about after discussion of "threaded > interpreters", confirming that the evaluation loop in Python 2 was not > exactly optimal. An op

Re: pointless musings on performance

2009-11-25 Thread Antoine Pitrou
Le Tue, 24 Nov 2009 22:08:19 +, Benjamin Peterson a écrit : > >> Would it be worth in-lining the remaining part of PyObject_IsTrue in >> ceval? > > Inlining by hand is prone to error and maintainability problems. Which is why we like to do it :-)) -- http://mail.python.org/mailman/listinf

Re: pointless musings on performance

2009-11-24 Thread Antoine Pitrou
Le Tue, 24 Nov 2009 08:58:40 -0800, Paul Boddie a écrit : > As you > point out, a lot of this RISC vs. CISC analysis (and inferences drawn > from Python bytecode analysis) is somewhat academic: the cost of the > JUMP_IF_FALSE instruction is likely to be minimal in the context of all > the activity

Re: xmlrpc idea for getting around the GIL

2009-11-24 Thread Antoine Pitrou
Le Tue, 24 Nov 2009 09:27:24 -0800, sturlamolden a écrit : > > Windows does not have daemons, so this is obviously incorrect. (There > are something called Windows Services, but multiprocessing does not use > them.) This is nitpicking. Technically it might not be a daemon but it's used as such.

Re: pointless musings on performance

2009-11-24 Thread Antoine Pitrou
Le Tue, 24 Nov 2009 15:11:29 +, Antoine Pitrou a écrit : > Hello, > > Le Tue, 24 Nov 2009 14:41:19 +0100, mk a écrit : >> >> As Rob pointed out (thanks): >> >> 11 31 LOAD_FAST0 (nonevar) >> 34 JUMP_IF_FALSE

Re: xmlrpc idea for getting around the GIL

2009-11-24 Thread Antoine Pitrou
Le Tue, 24 Nov 2009 02:53:30 -0800, sturlamolden a écrit : > On 22 Nov, 22:38, Patrick Stinson > 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 w

Re: pointless musings on performance

2009-11-24 Thread Antoine Pitrou
Hello, Le Tue, 24 Nov 2009 14:41:19 +0100, mk a écrit : > > As Rob pointed out (thanks): > > 11 31 LOAD_FAST0 (nonevar) > 34 JUMP_IF_FALSE4 (to 41) > > I'm no good at py compiler or implementation internals and so I have no > idea what bytecod

Re: Go versus Brand X

2009-11-24 Thread Antoine Pitrou
Le Mon, 23 Nov 2009 15:30:16 -0600, Robert Kern a écrit : > particularly constrained environments like editors that may not be > extensible at all. I'm not really an expert on this, but I think most good editors /are/ extensible (through plugins, scripts or other things). > You can get away wit

Re: Go versus Brand X

2009-11-23 Thread Antoine Pitrou
Le Mon, 23 Nov 2009 11:54:19 -0600, Robert Kern a écrit : > > Not really. The idea was to make the language easily parsed and lexed > and analyzed by *other* tools, not written in Go, that may have limited > capabilities. Well, if Go doesn't allow you to write libraries usable from other low- lev

Re: Go versus Brand X

2009-11-23 Thread Antoine Pitrou
Le Mon, 23 Nov 2009 02:36:33 -0600, Robert Kern a écrit : > > I think there is an overall design sensibility, it's just not a > human-facing one. They claim that they designed the syntax to be very > easily parsed by very simple tools in order to make things like syntax > highlighters very easy an

Re: Threaded import hang in cPickle.dumps

2009-11-11 Thread Antoine Pitrou
Le Tue, 10 Nov 2009 10:50:33 -0800, Zac Burns a écrit : > > cPickle.dumps has an import which is causing my application to hang. > (figured out by overriding builtin.__import__ with a print and seeing > that this is the last line of code being run. I'm running cPickle.dumps > in a thread, which le

Re: Cancelling a python thread (revisited...)

2009-11-09 Thread Antoine Pitrou
Le Sun, 08 Nov 2009 21:04:06 -0800, John Nagle a écrit : > Antoine Pitrou wrote: >> John Nagle animats.com> writes: >>> I'd argue against general thread cancellation. Inter-thread >>> signals, though, have safety problems no worse than the first-thread &g

Re: Cancelling a python thread (revisited...)

2009-11-08 Thread Antoine Pitrou
John Nagle animats.com> writes: > > I'd argue against general thread cancellation. Inter-thread > signals, though, have safety problems no worse than the first-thread > only signals we have now. You're allowed to raise an exception > in a signal handler, which is effectively thread cancella

Re: Cancelling a python thread (revisited...)

2009-11-08 Thread Antoine Pitrou
Le Sun, 08 Nov 2009 04:40:26 -0800, sven a écrit : > > I really don't get that. If the reason would be that it is too much > work to > implement, then I could accept it. It would probably be a lot of work and even then it would still be unsafe. Read for example: http://msdn.microsoft.com/en-us/

Re: What is the correct way to port codecs.open to python 3.1?

2009-11-07 Thread Antoine Pitrou
Le Sat, 07 Nov 2009 12:56:54 +0100, Baptiste Lepilleur a écrit : > > After applying 2to3.py to port a 2.6 script to 3.1, I get the following > error when running my script: > File "purekeyworddbtest.py", line 143, in __init__ > f = codecs.open(EXCLUDED_KEYWORDS_FILE, 'rt', 'utf-8') > File

Re: Cpython optimization

2009-10-23 Thread Antoine Pitrou
Le Fri, 23 Oct 2009 15:53:02 +0200, Olof Bjarnason a écrit : > > This would be way to speed up things in an image processing algorithm: > 1. divide the image into four subimages 2. let each core process each > part independently 3. fix&merge (along split lines for example) into a > resulting, comp

Re: Cpython optimization

2009-10-23 Thread Antoine Pitrou
Le Fri, 23 Oct 2009 09:45:06 +0200, Olof Bjarnason a écrit : > > So I think my first question is still interesting: What is the point of > multiple cores, if memory is the bottleneck? Why do you think it is, actually? Some workloads are CPU-bound, some others are memory- or I/O-bound. You will

Re: Anyone have python 3.1.1 installed on Solaris 10 ? (sparc or x86)

2009-10-20 Thread Antoine Pitrou
Hello, > Anyone have python 3.1.1 installed on Solaris 10 ? (sparc or x86) > > I've tried several times on sparc, I keep getting: [snip] If you don't get an answer on this list, I encourage you to file an issue on http://bugs.python.org Thank you Antoine. -- http://mail.python.org/mailman

Re: multi-threaded performance

2009-10-17 Thread Antoine Pitrou
Le Sat, 17 Oct 2009 06:54:29 +0200, Dieter Maurer a écrit : > > It is also true that adding CPUs may in fact reduce performance for > compute bound multithreaded Python programs. While the additional > computational resources cannot be use by Python, the additional overhead > (switching between CP

Re: python performance on Solaris

2009-10-15 Thread Antoine Pitrou
Le Wed, 14 Oct 2009 22:39:14 -0700, John Nagle a écrit : > > Note that multithreaded compute-bound Python programs really suck > on multiprocessors. Adding a second CPU makes the program go slower, > due to a lame mechanism for resolving conflicts over the global > interpreter lock. I'm not

Re: python performance on Solaris

2009-10-14 Thread Antoine Pitrou
inaf gmail.com> writes: > > Good point. I failed to compare the CPU power on these machines.. 32 > bit linux box I have is 2666 Mhz vs the Solaris zone is 1415 Mhz.. I > guess that explains :) Thank you for the tip.. You have to compare not only CPU frequencies but the CPU models. Recently Sun h

Re: python performance on Solaris

2009-10-11 Thread Antoine Pitrou
inaf gmail.com> writes: > > My code seem to > return lookups from a in memory data structure I build combining bunch > of dictionaries and lists 6-8 times faster on a 32 bit Linux box than > on a Solaris zone. Well, if your workload is CPU-bound, the issue here is not really Solaris vs. Linux bu

Re: Most "active" coroutine library project?

2009-09-24 Thread Antoine Pitrou
Grant Edwards invalid.invalid> writes: > > Back when I worked on one of the first hand-held cellular > mobile phones, it used co-routines where the number of > coroutines was fixed at 2 (one for each register set in a Z80 > CPU). Gotta love the lightning-fast EXX instruction. :-) Regards Antoi

Re: socket send O(N**2) complexity

2009-09-22 Thread Antoine Pitrou
twistedmatrix.com> writes: > > To the OP, you can get view-like behavior with the "buffer" builtin. And, on Python 3 (or even the 2.7 in development), you can use the "memoryview" builtin for similar effect. Regards Antoine. -- http://mail.python.org/mailman/listinfo/python-list

Re: An assessment of the Unicode standard

2009-08-30 Thread Antoine Pitrou
r gmail.com> writes: > > Why should the larger world > keep supporting such antiquated languages and character sets through > Unicode? What purpose does this serve? Are we merely trying to make > everyone happy? A sort of Utopian free-language-love-fest-kinda- > thing? Can you go and troll somew

Re: what is it, that I don't understand about python and lazy evaluation?

2009-08-13 Thread Antoine Pitrou
Erik Bernoth googlemail.com> writes: > > Isn't it strange, that this code runs (in a lazy language) for eternity? Python is a not a lazy language. `and` and `or` are particular, they are language constructs (*), not operators, that's why they can decide whether or not to evaluate their second te

Re: Social problems of Python doc [was Re: Python docs disappointing]

2009-08-12 Thread Antoine Pitrou
Paul Boddie boddie.org.uk> writes: > > A free-for-all isn't likely to be the best solution for more actively > edited Python documentation, but Wiki solutions undeniably provide a > superior "fast path" for edits by trusted users to be incorporated and > published in accessible end-user documenta

Re: Social problems of Python doc [was Re: Python docs disappointing]

2009-08-11 Thread Antoine Pitrou
r gmail.com> writes: > > On Aug 9, 11:02 pm, David Lyon wrote: > > Since you're talking about documentation, which is a part of python, > > don't you think you should be discussing it on python-dev ? > > Yea, them's be a friendly bunch to noob ideas ;). Hey i got a better > idea, lets go to the

Re: Tree structure consuming lot of memory

2009-07-06 Thread Antoine Pitrou
mayank gupta gmail.com> writes: > > After a little analysis, I found out that in general it uses about > 1.4 kb of memory for each node!! How did you measure memory use? Python objects are not very compact, but 1.4KB per object seems a bit too much (I would expect more about 150-200 bytes/object

Re: [RELEASED] Python 3.1 final

2009-06-29 Thread Antoine Pitrou
Nobody nowhere.com> writes: > > This results in an internal error: > > > "\udce4\udceb\udcef\udcf6\udcfc".encode("iso-8859-1", "surrogateescape") > Traceback (most recent call last): > File "", line 1, in > SystemError: Objects/bytesobject.c:3182: bad argument to internal function Please rep

Re: Passing contextual information when logging

2008-01-08 Thread Antoine Pitrou
Hi Vinay, > I would welcome your views on whether the LoggerAdapter class is > suitable for adding to the logging package in Python 2.6/3.0. Does it > do what might reasonably be expected out of the box? I think it's quite suited to the problem, yes. One question : why does the exception() meth

parameterized metaclass (or metametaclass)

2005-01-06 Thread Antoine Pitrou
Hi, I've been looking at writing parameterized metaclasses and here are the two solutions I've come to: (my goal was to build a way to automatically add a hash function that would take into account a selected list of object attributes) 1. all-in-one metametaclass: class Autohash2(type): """

<    1   2   3