Re: issubclass(dict, Mapping)

2010-12-22 Thread Antoine Pitrou
On Wed, 22 Dec 2010 14:20:51 + (UTC) kj wrote: > > So dict is a subclass of Mapping, even though none of the bases of > dict is either Mapping or a subclass of Mapping. Great. > > I suspect this is another abstraction leak ("dict is *supposed* to > be a Python class like all others, but in

Re: True lists in python?

2010-12-19 Thread Antoine Pitrou
On Sun, 19 Dec 2010 20:45:55 +0100 Stefan Sonnenberg-Carstens wrote: > Am 19.12.2010 07:18, schrieb Dmitry Groshev: > > Is there any way to use a true lists (with O(c) insertion/deletion and > > O(n) search) in python? For example, to make things like reversing > > part of the list with a constant

Re: Python critique

2010-12-10 Thread Antoine Pitrou
On Fri, 10 Dec 2010 12:02:21 -0800 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. Please stop spreading FUD: http://docs.python.org/c-api/i

Re: Proposed changes to logging defaults

2010-12-10 Thread Antoine Pitrou
On Fri, 10 Dec 2010 11:17:33 +0100 Jean-Michel Pichavant wrote: > Why would you log informative messages to stderr ? (debug, info, warning) > How stderr is a better choice than stdout ? By construction really. stderr is initially for errors, but it is generally used for "out of band" messages suc

Re: 64 bit memory usage

2010-12-09 Thread Antoine Pitrou
On Thu, 9 Dec 2010 17:18:58 + Rob Randall wrote: > Basically the process runs at around 1% and it never seems to grow in size > again. > When running the C++ with python app the process slows when a new 'page' is > required but then goes back to 'full' speed. It does this until basically > all

Re: 64 bit memory usage

2010-12-09 Thread Antoine Pitrou
On Wed, 8 Dec 2010 14:44:30 + Rob Randall wrote: > I am trying to understand how much memory is available to a 64 bit python > process running under Windows XP 64 bit. > > When I run tests just creating a series of large dictionaries containing > string keys and float values I do not seem to

Re: Perceived inconsistency in py3k documentation

2010-12-06 Thread Antoine Pitrou
On Sun, 05 Dec 2010 14:47:38 -0500 Terry Reedy wrote: > On 12/5/2010 3:31 AM, Greg wrote: > > For future reference, > > > 1) At http://docs.python.org/py3k/reference/datamodel.html: > > 2) At http://docs.python.org/py3k/library/stdtypes.html: > > do not work because of the trailing :s, at least

Re: When to use codecs vs. io module (Python 2.7 and higher)

2010-12-01 Thread Antoine Pitrou
On Wed, 01 Dec 2010 09:55:01 -0500 pyt...@bdurham.com wrote: > Python 2.7 or higher: Looking for reasons/scenarios where one > should use the codecs vs. io module. > > Are there use cases that favor one specific module over the other > module? > > My understanding is that the io module is much fa

Re: To Thread or not to Thread....?

2010-12-01 Thread Antoine Pitrou
On Wed, 1 Dec 2010 23:48:38 +1000 James Mills wrote: > Surely I2C is just a serial-like interface > and one should be able to do async I/O on it ? > > The use of threads is not necessary here and the GIL > doesn't become a problem in async I/O anyway. Well, you are missing the point. The OP want

Re: To Thread or not to Thread....?

2010-12-01 Thread Antoine Pitrou
On Wed, 1 Dec 2010 11:50:46 + Jack Keegan wrote: > Hi Antoine, > > On Wed, Dec 1, 2010 at 9:24 AM, Antoine Pitrou wrote: > > > > > > The main question IMO: the I2C bus operates at 400kHz, but how much > > received data can it buffer? That will give you a hi

Re: To Thread or not to Thread....?

2010-12-01 Thread Antoine Pitrou
On Wed, 1 Dec 2010 02:45:50 + Jack Keegan wrote: > Hi there, > > I'm currently writing an application to control and take measurements during > an experiments. This is to be done on an embedded computer running XPe so I > am happy to have python available, although I am pretty new to it. > T

Re: Python 3 encoding question: Read a filename from stdin, subsequently open that filename

2010-12-01 Thread Antoine Pitrou
On Tue, 30 Nov 2010 22:22:01 -0500 Albert Hopkins wrote: > And I can freely copy > these "invalid" files across different (Unix) systems, because the OS > doesn't care about encoding. And so can Python, thanks to PEP 383. > > That's where encodings which can be used globally come in. > > By the

Re: Python 3 encoding question: Read a filename from stdin, subsequently open that filename

2010-12-01 Thread Antoine Pitrou
On Tue, 30 Nov 2010 16:57:57 -0800 Dan Stromberg wrote: > >> --- On Tue, 11/30/10, Dan Stromberg wrote: > >> > In Python 3, I'm finding that I have encoding issues with > >> > characters > >> > with their high bit set.  Things are fine with strictly > >> > ASCII > >> > filenames.  With high-bit-s

Re: Memory issues when storing as List of Strings vs List of List

2010-11-30 Thread Antoine Pitrou
On Tue, 30 Nov 2010 18:29:35 +0800 OW Ghim Siong wrote: > > Does anyone know why is there such a big difference memory usage when > storing the matrix as a list of list, and when storing it as a list of > string? That's because any object has a fixed overhead (related to metadata and allocatio

Re: Python 3 encoding question: Read a filename from stdin, subsequently open that filename

2010-11-30 Thread Antoine Pitrou
On Mon, 29 Nov 2010 21:52:07 -0800 (PST) Yingjie Lan wrote: > --- On Tue, 11/30/10, Dan Stromberg wrote: > > In Python 3, I'm finding that I have encoding issues with > > characters > > with their high bit set.  Things are fine with strictly > > ASCII > > filenames.  With high-bit-set characters,

Re: Python 2.7.1

2010-11-30 Thread Antoine Pitrou
On Mon, 29 Nov 2010 15:11:28 -0800 (PST) Spider wrote: > > 2.7 includes many features that were first released in Python 3.1. The > > faster io module ... > > I understand that I/O in Python 3.0 was slower than 2.x (due to quite > a lot of the code being in Python rather than C, I gather), and t

Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance

2010-11-24 Thread Antoine Pitrou
On Wed, 24 Nov 2010 12:08:04 -0800 (PST) Raymond Hettinger wrote: > I'm writing-up more guidance on how to use super() and would like to > point at some real-world Python examples of cooperative multiple > inheritance. > > Google searches take me to old papers for C++ and Eiffel, but that > don't

Re: with HTTPConnection as conn:

2010-11-18 Thread Antoine Pitrou
On Thu, 18 Nov 2010 12:46:07 +0100 trylks wrote: > Hi! > > Would it be possible to use a with statement with an HTTPConnection object? > > I know it is not possible at this moment, it doesn't implement an > __exit__ method, at least in version 3.1.1. I was wondering if the > __exit__ method shou

Re: Is a 32-bit build faster than a 64-bit build

2010-11-13 Thread Antoine Pitrou
On Fri, 12 Nov 2010 13:24:09 -0800 (PST) Raymond Hettinger wrote: > Has anyone here benchmarked a 32-bit Python versus a 64-bit Python for > Django or some other webserver? > > My hypotheses is that for apps not needing the 64-bit address space, > the 32-bit version has better memory utilization

Re: Passing File Objects into Subprocess.Popen

2010-11-04 Thread Antoine Pitrou
On Thu, 04 Nov 2010 17:13:09 -0500 Brandon Harris wrote: > I'm running python 2.5 and have bumped into an issue whereby the PIPE > in subprocess.Popen locks up after taking too many characters. I found > some documentation that discuss this problem and offers some ideas for > solutions, the b

Re: Python documentation too difficult for beginners

2010-11-02 Thread Antoine Pitrou
On Tue, 2 Nov 2010 04:23:49 -0700 (PDT) jk wrote: > This (http://epydoc.sourceforge.net/stdlib/) is what I'm talking > about. > > Why aren't the official docs like this, and why has it taken me 2 days > of searching? What's wrong with this: http://docs.python.org/library/ ? If you have specific

Re: multiprocessing signal defect

2010-10-29 Thread Antoine Pitrou
On Fri, 29 Oct 2010 08:12:19 -0400 Neal Becker wrote: > Seems multiprocessing doesn't behave well with signals: > [...] By the way, could you post an issue on the tracker with instructions on how to reproduce (including OS)? Thanks Antoine. -- http://mail.python.org/mailman/listinfo/python-l

Re: multiprocessing signal defect

2010-10-29 Thread Antoine Pitrou
On Fri, 29 Oct 2010 10:08:01 -0400 Adam Tauno Williams wrote: > > No, I don't think so. You're asking the module to over generalize > behavior. Reaping of the child is important, and that the child needs > to be reaped may matter to the master child (why? did something go > wrong?). Silently r

Re: Suppressing __context__

2010-10-29 Thread Antoine Pitrou
On Fri, 29 Oct 2010 04:07:15 -0700 Chris Rebert wrote: > On Fri, Oct 29, 2010 at 4:02 AM, Antoine Pitrou wrote: > > On Sun, 24 Oct 2010 10:48:23 +0200 > > "Martin v. Loewis" wrote: > >> > >> You may now wonder whether it is possible to set __c

Suppressing __context__

2010-10-29 Thread Antoine Pitrou
On Sun, 24 Oct 2010 10:48:23 +0200 "Martin v. Loewis" wrote: > > You may now wonder whether it is possible to set __context__ to None > somehow. See PEP 3134: > > Open Issue: Suppressing Context > > As written, this PEP makes it impossible to suppress '__context__', > since setting exc.

Re: nntplib and ssl

2010-10-22 Thread Antoine Pitrou
On Fri, 22 Oct 2010 17:02:07 -0400 Andrew wrote: > > Python's nntplib seems ideal for my purposes, but as far as I can see it > doesn't support nntps connections. If I understand nntp correctly (I may > not) that means, among other things, it sends passwords in cleartext. > > That won't do. I n

Re: socket.sendto / UDP problem

2010-10-22 Thread Antoine Pitrou
On Fri, 22 Oct 2010 09:27:51 -0400 Todd Walter wrote: > Is there a way to specify the source port for a > transmission without first binding to it? Of course not, why do you want to do so? (well, not using plain UDP or TCP, that is. You can of course do that through ad-hoc means in the applicatio

Re: Performance evaluation of HTTPS library

2010-10-14 Thread Antoine Pitrou
On Thu, 14 Oct 2010 05:06:30 -0700 (PDT) Ashish wrote: > > One more question: If I run the tool from multicore machine, will > python3.1 or 3.2 be able to actually use multicore? or it will be > running only on one core? Only partly. Pure Python code is serialized (by the Global Interpreter Lock

Re: Performance evaluation of HTTPS library

2010-10-13 Thread Antoine Pitrou
On Wed, 13 Oct 2010 05:27:29 -0700 (PDT) Ashish wrote: > > Well, CBSocket is socket implementation that calls my callback on > data. > Both my classes AsyncHTTPSConnection and AsyncHTTPConnection use it > and use it the same way ( self.sock = CBSocket(sock2) ). > The implemetation of AsyncHTTPCon

Re: Performance evaluation of HTTPS library

2010-10-13 Thread Antoine Pitrou
On Wed, 13 Oct 2010 02:12:21 -0700 (PDT) Ashish wrote: > > > > > Is the client machine at 100% CPU when you do that? > > > > With HTTP, I see client CPU at appx. 97%. However with HTTPS, it stays > > at 53-55%. And is the server at 100% CPU then? If the client is not at 100% CPU, it shouldn't be

Re: PEP 249 (database api) -- executemany() with iterable?

2010-10-12 Thread Antoine Pitrou
On Tue, 12 Oct 2010 13:58:37 -0400 Terry Reedy wrote: > On 10/12/2010 11:10 AM, Roy Smith wrote: > > PEP 249 says about executemany(): > > > > Prepare a database operation (query or command) and then > > execute it against all parameter sequences or mappings > > found in

Re: Performance evaluation of HTTPS library

2010-10-12 Thread Antoine Pitrou
On Tue, 12 Oct 2010 05:40:43 -0700 (PDT) Ashish Vyas wrote: > > I have made a tool for load testing of my company's web-server product. The > tool > is written using Python 3.1. > [...] > > So I feel HTTPS is blocking my test if I want to achieve higher TPS > (transactions per second.) than

Re: Wrong default endianess in utf-16 and utf-32 !?

2010-10-12 Thread Antoine Pitrou
On Tue, 12 Oct 2010 06:28:23 -0700 (PDT) jmfauth wrote: > I hope my understanding is correct and I'm not dreaming. > > When an endianess is not specified, (BE, LE, unmarked forms), > the Unicode Consortium specifies, the default byte serialization > should be big-endian. > [...] > > It appears

Re: Performance evaluation of HTTPS library

2010-10-12 Thread Antoine Pitrou
On Tue, 12 Oct 2010 05:40:43 -0700 (PDT) Ashish Vyas wrote: > Another observation that I have made is with 10 parallel HTTPS connection > each > trying 1 transaction per second from 2 different machines (effectively same > load > on server), the response time is again reducing to .17 secs. > H

Re: harmful str(bytes)

2010-10-11 Thread Antoine Pitrou
On Mon, 11 Oct 2010 21:50:32 +0200 Hallvard B Furuseth wrote: > > I'd just posted an example in article : > > urllib.parse.urlunparse(('', '', '/foo', b'bar', '', '')) returns > "/foo;b'bar'" instead of raising an exception or returning 2.6's correct > "/foo;bar". Oh, this looks like a bug in u

Re: harmful str(bytes)

2010-10-08 Thread Antoine Pitrou
On Fri, 08 Oct 2010 15:45:58 +0200 Hallvard B Furuseth wrote: > Antoine Pitrou writes: > >Hallvard B Furuseth wrote: > >> The offender is bytes.__str__: str(b'foo') == "b'foo'". > >> It's often not clear from looking at a piece

Re: harmful str(bytes)

2010-10-08 Thread Antoine Pitrou
On Thu, 07 Oct 2010 23:33:35 +0200 Hallvard B Furuseth wrote: > > The offender is bytes.__str__: str(b'foo') == "b'foo'". > It's often not clear from looking at a piece of code whether > some data is treated as strings or bytes, particularly when > translating from old code. Which means one cann

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-06 Thread Antoine Pitrou
On Tue, 05 Oct 2010 16:17:57 +0200 "Jonas H." wrote: > > Right now I have this minimal struct: > > static PyTypeObject StartResponse_Type = { > PyObject_HEAD_INIT(&PyType_Type) > 0, /* ob_size */ > "start_response", /* tp_name */ > sizeof(St

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-04 Thread Antoine Pitrou
On Mon, 04 Oct 2010 23:30:58 +0200 "Jonas H." wrote: > > > [...] here's a minimal, but __complete__, module that defines a new type: > > > > [...] > > static PyTypeObject noddy_NoddyType = { > > [...] > > 0, /*tp_dealloc*/ > > [...] > > }; > > So I thought "co

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-03 Thread Antoine Pitrou
On Sun, 03 Oct 2010 16:33:48 +0200 "Jonas H." wrote: > > Humm. Now the behaviour is as follows: > > with assignment to local variable > -- > * start_response = PyObject_NEW(...) -> start_response->ob_refcnt=1 > * wsgiapp(environ, start_response) ->

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-03 Thread Antoine Pitrou
On Sun, 03 Oct 2010 14:44:32 +0200 "Jonas H." wrote: > On 10/03/2010 01:16 AM, Antoine Pitrou wrote: > > You should check that you aren't doing anything wrong > > with "env" and "start_response" (like deallocate them forcefully). > > I comm

Re: SQLite is quite SQL compliant

2010-10-02 Thread Antoine Pitrou
On Sat, 2 Oct 2010 19:13:11 -0400 Philip Semanchuk wrote: > > On Oct 2, 2010, at 6:58 PM, Tim Chase wrote: > > > On 10/02/10 17:06, Seebs wrote: > >> On 2010-10-02, Ravi wrote: > >>> The documentation of the sqlite module at > >>> http://docs.python.org/library/sqlite3.html says: > >> > >>> ".

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-02 Thread Antoine Pitrou
On Sat, 02 Oct 2010 23:35:01 +0200 "Jonas H." wrote: > > This WSGI application: > >def app(env, start_response): >start_response('200 alright', []) >try: >a >except: >import sys >sys.exc_info() >return ['hello'] > >impo

Re: How to find free resident memory in Linux using python

2010-10-02 Thread Antoine Pitrou
On Sat, 2 Oct 2010 07:06:37 -0700 (PDT) Sandy wrote: > Hi all, > I want to find how much free memory (RAM) is available in my system > using python. Take a look at http://www.selenic.com/smem/ It's written in Python. Regards Antoine. -- http://mail.python.org/mailman/listinfo/python-list

Re: __file__ is sometimes absolute, sometimes relative

2010-10-01 Thread Antoine Pitrou
On Fri, 1 Oct 2010 21:00:02 +0200 Sébastien Barthélemy wrote: > Hi, > > Arnaud, Christian, thank you for your help. > > I'll use abspath, it's shorter. > > Any idea why it's sometimes absolute, sometimes not? AFAICT, that's because sys.path contains some absolute paths and some relative ones.

Re: Determine sockets in use by python

2010-10-01 Thread Antoine Pitrou
On Thu, 30 Sep 2010 12:32:45 -0700 Jim Mellander wrote: > Thanks, I realized that even if I found out relevant info on the > socket, I would probably need to use ctypes to provide a low level > interface to select, as the socket wouldn't be a python socket object, > unless there is some way to pr

Re: Python becoming orphaned over ssh

2010-10-01 Thread Antoine Pitrou
On Thu, 30 Sep 2010 07:01:09 -0700 (PDT) Jean-Paul Calderone wrote: > > But signal dispositions are inherited by child processes. So you run > ping from your short Python program, and it inherits SIGPIPE being > ignored. And it's written in C, not Python, so when it writes to the > pipe, there'

Re: PyCObject & malloc creating memory leak

2010-09-30 Thread Antoine Pitrou
On Thu, 30 Sep 2010 04:06:03 -0700 (PDT) Tom Conneely wrote: > Thanks for your reply, you've given me plenty to think about > > On Sep 29, 11:51 pm, Antoine Pitrou wrote: > > > > > My original plan was to have the data processing and data acquisition > &

Re: Certificate validation with HTTPSConnection

2010-09-29 Thread Antoine Pitrou
On Wed, 29 Sep 2010 13:41:15 -0700 John Nagle wrote: > > The really stupid thing about the current SSL module is that it > accepts a file of root certificates as a parameter, but ignores it. That's not true. You have to pass CERT_OPTIONAL or CERT_REQUIRED as a parameter (CERT_NONE is though). R

Re: PyCObject & malloc creating memory leak

2010-09-29 Thread Antoine Pitrou
On Wed, 29 Sep 2010 06:50:05 -0700 (PDT) Tom Conneely wrote: > > My original plan was to have the data processing and data acquisition > functions running in separate processes, with a multiprocessing.Queue > for passing the raw data packets. The raw data is read in as a char*, > with a non const

Re: Python in Linux - barrier to Python 3.x

2010-09-21 Thread Antoine Pitrou
On Tue, 21 Sep 2010 17:59:27 +0200 de...@web.de (Diez B. Roggisch) wrote: > > The problems explained are simply outdated and crippled python > versions. > > And to me, a python version installed that has not the > distutils module is *crippled*. You can rationalize that as much as you > want thr

Re: Embedded Systems development using Python

2010-09-06 Thread Antoine Pitrou
On Mon, 6 Sep 2010 17:22:09 +0530 VGNU Linux wrote: > Hi, > > A small device like a mobile but with only 2 major buttons, with GPS and > GPRS capabilities. > Can anyone tell me from where to start learning about this ? Read the official docs for the C API: http://docs.python.org/extending/embedd

Re: Speed-up for loops

2010-09-06 Thread Antoine Pitrou
On Mon, 06 Sep 2010 13:20:01 +0200 Stefan Behnel wrote: > > > (2) Integer arithmetic seems to go straight from 32-bits to long > > integers; why not use 64-bits before needing long integers? > > You are making assumptions based on Python 2, I guess. Try Python 3.1 or > later instead, where the

Re: PyInt_FromLong gives segfault on small numbers (<257)

2010-08-05 Thread Antoine Pitrou
On Thu, 5 Aug 2010 05:04:36 -0700 (PDT) Marcos Prieto wrote: > Hi, > > I'm trying to call python (python 2.6) functions from C++ using MS VC+ > + 6.0 and any calls to PyInt_FromLong with numbers below 257 give me > exceptions, no problems with bigger numbers > > PyObject *pValue; > > pValue = P

Re: please, help with python 3.1

2010-08-03 Thread Antoine Pitrou
On Tue, 3 Aug 2010 10:28:49 +0100 Alan Wilter Sousa da Silva wrote: > Now with python3.1: > > > time python3.1 timout.py > PID: 27687 > Timed out! Process 27687 killed, max exec time (5s) exceeded > Traceback (most recent call last): > File "

Re: Newbie question regarding SSL and certificate verification

2010-07-29 Thread Antoine Pitrou
On Wed, 28 Jul 2010 22:23:48 -0700 geremy condra wrote: > > > >   The new Python SSL module in 2.6 and later has a huge built-in > > security hole - it doesn't verify the domain against the > > certificate.  As someone else put it, this means "you get to > > talk securely with your attacker." As l

Re: Best practice way to open files in Python 2.6+?

2010-07-27 Thread Antoine Pitrou
On Tue, 27 Jul 2010 10:33:06 -0400 pyt...@bdurham.com wrote: > What is the best practice way to open files in Python 2.6+ > > It looks like there are at least 3 different ways to open files: > - built-in open() > - io.open() > - codecs.open() > It seems like io.open() combines the best of the buil

Re: ANN: blist 1.2.0

2010-07-21 Thread Antoine Pitrou
On Wed, 21 Jul 2010 09:47:08 -0500 Daniel Stutzbach wrote: > > What's new? > --- > > - blist.sort() is now *substantially* faster than list.sort() when using int > or float keys (O(n) vs. O(n log n)) Are you using some kind of radix sort? Could it be contributed back into the standard l

Re: Exposing buffer interface for non-extension types?

2010-07-21 Thread Antoine Pitrou
On Tue, 20 Jul 2010 18:09:22 -0400 Ken Watford wrote: > Is there any way to expose the PEP 3118 buffer interface for objects > that aren't extension types? > > Currently, I can expose the NumPy array interface (using either > __array_interface__ or __array_struct__) for any class, extension or >

Re: CPython Signal Handler Check for SIGKILL

2010-07-19 Thread Antoine Pitrou
Hello, > I am not asking about the signals, I understand them, > I am asking about the registration of the SIGNAL handler and how it knows > that you are trying to register SIGKILL, you get an error like this. > > ./signal-catcher.py > Traceback (most recent call last): > File "./signal-catch

Re: [ANN] inflect.py: generate plurals, ordinals, numbers to words...

2010-07-16 Thread Antoine Pitrou
On Fri, 16 Jul 2010 17:29:44 +0200 Daniel Fetchinson wrote: > I'm pleased to announce the release of inflect.py v0.1.8, a module that > correctly generates: > > * the plural of singular nouns and verbs > * the singular of plural nouns > * ordinals > * indefinite

Re: Why doesn't python's list append() method return the list itself?

2010-07-11 Thread Antoine Pitrou
On Sun, 11 Jul 2010 08:59:06 -0700 (PDT) dhruvbird wrote: > Why doesn't python's list append() method return the list itself? For > that matter, even the reverse() and sort() methods? > I found this link (http://code.google.com/edu/languages/google-python- > class/lists.html) which suggests that t

Re: Sumatra m/l?

2010-07-10 Thread Antoine Pitrou
On 10 Jul 2010 13:48:09 -0700 a...@pythoncraft.com (Aahz) wrote: > > Also, it's pretty rude to set followups to gmane.comp.python.general Can you expand? -- http://mail.python.org/mailman/listinfo/python-list

Re: Any reason www.python.org is slow?

2010-07-10 Thread Antoine Pitrou
On Sat, 10 Jul 2010 16:28:19 +0200 "Martin v. Loewis" wrote: > >> If your computer does have IPv6 connectivity, but it's broken > >> (i.e. you have a gateway, but eventually packets are discarded), > >> you see the IPv4 fallback after the IPv6 timeout. The IPv4 connection in > >> itself then would

Re: Any reason www.python.org is slow?

2010-07-10 Thread Antoine Pitrou
On Sat, 10 Jul 2010 16:03:24 +0200 "Martin v. Loewis" wrote: > > That is a common myth. If your computer doesn't have any IPv6 > connectivity, all is fine. The web browser will fallback to IPv4 > immediately (*), without sending out any IPv6 datagrams first. Ok, I suppose the explanation wasn't

Re: Any reason www.python.org is slow?

2010-07-10 Thread Antoine Pitrou
On Sat, 10 Jul 2010 06:30:11 -0700 (PDT) Pierre Rouleau wrote: > All, > > I have been finding python.org site very slow for the last year and > probably before. Is there any known reason why the site is slow? For the last year?? It's been mostly zippy here. Is IPv6 enabled on your computer? If s

Re: Changing Locale for datetime.strptime conversions

2010-07-06 Thread Antoine Pitrou
On Tue, 06 Jul 2010 11:54:46 -0400 pyt...@bdurham.com wrote: > Antoine, > > > If you want to do this seriously, I suggest you instead take a look at > > third-party libraries such as Babel: http://babel.edgewall.org/ > > Not the OP, but has Babel implemented parsing support? Last time I > looked

Re: Changing Locale for datetime.strptime conversions

2010-07-06 Thread Antoine Pitrou
On Tue, 6 Jul 2010 03:21:21 -0700 (PDT) AlienBaby wrote: > I'm still having a bit of trouble, for example trying to set the > locale to Denmark > > > locale.setlocale(locale.LC_ALL, locale.normalize('da_DK')) > > returns with > > locale.setlocale(locale.LC_ALL, locale.normalize('da_DK'))

Re: SMTPHandler and Unicode

2010-07-05 Thread Antoine Pitrou
On Mon, 5 Jul 2010 06:17:38 -0700 (PDT) norbert wrote: > > a FileHandler works as expected, the log file being UTF-8 encoded. Ouch. Implicit encoding sounds like a bad behaviour. > The > SMTPHandler is the only logger I know with this problem, maybe > connected to SMTPLib implementation ? I su

Re: Python 3 put-downs: What's the point?

2010-07-05 Thread Antoine Pitrou
On Sun, 4 Jul 2010 18:20:38 -0700 (PDT) CM wrote: > > Any online group is an opportunity to register dissent in a way that > is public, open, immediate, interactive, and will (probably) be > preserved for historians to check. The fact is, some people have > gripes with Python 3; they are letting

Re: Crash in PyThread_acquire_lock

2010-07-03 Thread Antoine Pitrou
Hello, > 'thelock->locked' is for sure still locked, but I can't identify the > problem. > Its just waiting, but it gets a 'EXC_BAD_ACCESS'. The line of the > crash > in PyThread_acquire_lock is the following one: > > while ( thelock->locked ) { > status = pthread_cond_wait(&thelock->lock_re

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

2010-07-02 Thread Antoine Pitrou
On Mon, 28 Jun 2010 16:46:41 -0700 Zac Burns wrote: > In my experience it is far more expensive to allocate a lock in python then > it is the types that use them. Here are some examples: > > >>> timeit.timeit('Lock()', 'from threading import Lock') > 1.4449114807669048 > > >>> timeit.timeit('dic

Re: Python OpenSSL library

2010-06-17 Thread Antoine Pitrou
On Tue, 15 Jun 2010 19:56:46 -0700 John Nagle wrote: > > http://bugs.python.org/issue1589 [...] > > The typical Python user will expect SSL checking for URL opening > to behave like a browser does. They won't be up to speed on the > internal mechanics of X.509 certificates. The default cas

Re: Python OpenSSL library

2010-06-15 Thread Antoine Pitrou
On Tue, 15 Jun 2010 14:14:08 -0700 geremy condra wrote: > > > > Ok, thank you. > > I have tried to put some effort into the py3k ssl docs, so that security > > issues get mentioned: > > http://docs.python.org/dev/py3k/library/ssl.html#security-considerations > > Any improvement or correction is we

Re: Python OpenSSL library

2010-06-15 Thread Antoine Pitrou
Hello, > He's describing the lack of hostname checking, discussed here[0], > here[1], and in my pycon lightning talk last year, wherever those > are kept. Ok, thank you. I have tried to put some effort into the py3k ssl docs, so that security issues get mentioned: http://docs.python.org/dev/py3k

Re: Python OpenSSL library

2010-06-15 Thread Antoine Pitrou
On Mon, 14 Jun 2010 19:47:49 +0100 Nobody wrote: > On Mon, 14 Jun 2010 10:43:02 -0700, John Nagle wrote: > > > The new SSL module in Python 2.6 > > There isn't an SSL module in Python 2.6. There is a module named "ssl" > which pretends to implement SSL, but in fact doesn't. What do you mean

Re: Python OpenSSL library

2010-06-14 Thread Antoine Pitrou
On Mon, 14 Jun 2010 11:05:50 -0700 geremy condra wrote: > > Yes. Hashlib is designed to provide cryptographic hashes, and the ssl > module to provide TLS support. Evpy provides encryption and signing. > Am I answering your question? Hmm, indeed, thank you. For some strange reason I had forgotten

Re: Standard Library SSL Module (was: Python OpenSSL library)

2010-06-14 Thread Antoine Pitrou
On Mon, 14 Jun 2010 15:54:33 -0400 Michael Crute wrote: > On Mon, Jun 14, 2010 at 1:25 PM, Antoine Pitrou wrote: > > That was not my question. My question was whether there was a reason to > > rewrite a separate OpenSSL-accessing library rather than contributing to > > impr

Re: Python OpenSSL library

2010-06-14 Thread Antoine Pitrou
Le lundi 14 juin 2010 à 13:18 -0400, geremy condra a écrit : > >> > >> Evpy[1] is designed to be a very easy-to-use interface to OpenSSL, > >> although it is by design limited to doing things the right way, so it > >> may not meet your needs. > > > > How about contributing to the standard hashlib a

Re: Python OpenSSL library

2010-06-14 Thread Antoine Pitrou
On Sun, 13 Jun 2010 14:13:32 -0700 geremy condra wrote: > On Sun, Jun 13, 2010 at 1:29 PM, astral > wrote: > > I am looking for Python OpenSSL library, for Python version 2.5.4 (on > > Windows) > > Which does not require to install Cygwin package. Need just to decrypt file, > > then uninstall lib

optional optional args vs optional positional options

2010-06-02 Thread Antoine Pitrou
On Wed, 2 Jun 2010 01:49:18 -0700 (PDT) Michele Simionato wrote: > > Notice that optparse is basically useless in the use case Tim is > considering (positional arguments) since it only manages options. By the way, could you stop naming these "optional arguments", since positional arguments can b

Re: MySQLdb install vs. "setuptools"

2010-05-30 Thread Antoine Pitrou
On Sun, 30 May 2010 15:16:42 -0700 John Nagle wrote: > > It's nice that some of the options work. Note that someone who > used "--bindir", expecting it to work, might end up overwriting their > existing Python installation unintentionally, which would break system > administration tools lik

Re: MySQLdb install vs. "setuptools"

2010-05-30 Thread Antoine Pitrou
On Sun, 30 May 2010 10:10:00 -0700 John Nagle wrote: > > Actually, a "built" but "uninstalled" Python works fine. > If it > didn't, "make test" wouldn't work. That's a completely unrelated thing. The main reason "make test" works with an uninstalled Python is simply so that the core develo

Re: MySQLdb install vs. "setuptools"

2010-05-30 Thread Antoine Pitrou
Really, this shouldn't happen if you really are using a non-root version of Python: > [Errno 2] No such file or directory: > '/usr/local/lib/python2.6/site-packages/test-easy-install-22015.write-test' I don't think setuptools is dumb enough to hardcode things like "/usr/local/lib/python2.6

Re: Generator expressions vs. comprehensions

2010-05-24 Thread Antoine Pitrou
On Mon, 24 May 2010 15:47:32 -0700 (PDT) Carl Banks wrote: > > > > Is this distinction generally known? Yes, it is. > > The generator expression > > behavior is understandable since a generator would do the same thing, > > but I'm disappointed that the inconsistency exists and wasn't fixed in >

Re: Python3 buffer extra byte??

2010-05-17 Thread Antoine Pitrou
On Mon, 17 May 2010 20:34:21 +0200 Dodo wrote: > Let's consider this code: > > #!/usr/bin/python3 > import cgi, sys > print("Content-type:image/jpeg\n\n") print() adds an additional \n, so there's one too many. Also, HTTP headers should be separated with \r\n, not \n. (besides, under Windows \

Re: Problem displaying jpgs in Tkinter via PIL

2010-05-11 Thread Antoine Pitrou
On Tue, 11 May 2010 09:57:01 -0700 Armin wrote: > Never mind, I gave up on Tkinter and have switched to wxPython now. > Getting jpg images to display in a wx frame worked like a charm... (As > I said, I'm very new to Python, so I didn't really know what my options > for GUI programming were.)

Re: urllib.urlopen blocking?

2010-05-11 Thread Antoine Pitrou
On Tue, 11 May 2010 07:35:52 -0700 (PDT) Dominik Gabi wrote: > > For the record, have you tried calling gobject.threads_init() at the > > beginning of your application (just after importing all modules)? > > I haven't... now it works, thanks :) Any tips on how to avoid mistakes > like that in th

Re: urllib.urlopen blocking?

2010-05-11 Thread Antoine Pitrou
On Tue, 11 May 2010 06:22:29 -0700 (PDT) Dominik Gabi wrote: > > I'm new to python and have been playing around with it for a few days > now. So please forgive me if this is a stupid question :) > > I've tried writing a little application with pygtk and urllib. For the record, have you tried ca

Re: INCREF DECREF manually

2010-05-10 Thread Antoine Pitrou
On Mon, 10 May 2010 07:26:42 -0700 (PDT) moerchendiser2k3 wrote: > > Do to some debugging if a version contains a bug and needs to be fixed > there manually. This is certainly the wrong approach. To know if your Python code is leaking references, use either sys.getrefcount(), or (better) a weakr

Re: zlib.decompress fails, zlib.decompressobj succeeds - bug or feature?

2010-05-09 Thread Antoine Pitrou
On Sun, 9 May 2010 09:25:16 -0700 (PDT) Matthew Brett wrote: > > How about: > > > > d = zlib.decompressobj() > > out = d.decompress(data) + d.flush() > > Do you mean, that you would then expect the decompressobj method to > fail as well? Yes. > But, no, d.flush() returns the empty string after

Re: zlib.decompress fails, zlib.decompressobj succeeds - bug or feature?

2010-05-09 Thread Antoine Pitrou
On Sun, 9 May 2010 01:28:14 -0700 (PDT) Matthew Brett wrote: > > If instead I do this: > > out = zlib.decompressobj().decompress(data) How about: d = zlib.decompressobj() out = d.decompress(data) + d.flush() ? Notice the documentation for decompressobj.decompress (emphasis mine): “Decompres

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-08 Thread Antoine Pitrou
On Sat, 8 May 2010 13:47:53 +0200 Giampaolo Rodolà wrote: > > Assuming loop() function does something like this: > > ... > select.select(r, w, e, timeout) > scheduler() # checks for scheduled calls to be fired > ... > > ...imagine a case where there's a connection (aka a di

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-07 Thread Antoine Pitrou
Le Fri, 07 May 2010 21:55:15 +0200, Giampaolo Rodolà a écrit : > Of course, but 30 seconds look a little bit too much to me, also because > (I might be wrong here) I noticed that a smaller timeout seems to result > in better performances. That's probably bogus. > Plus, if scheduled callbacks are

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-07 Thread Antoine Pitrou
Le Fri, 07 May 2010 16:36:44 +0200, Giampaolo Rodolà a écrit : > You can easily avoid this by setting a lower timeout when calling > asyncore.loop(), like 1 second or less (for example, Twisted uses 0.001 > secs). > Actually there's no reason for asyncore to have such a high default > timeout (30 s

Re: building python 3 -- _dbm necessary bits

2010-04-30 Thread Antoine Pitrou
Le Fri, 30 Apr 2010 08:14:21 -0700, Mark Olbert a écrit : > > Do you know how I can report this issue to the developers so that the > Python build script can be modified to look for the gdbm files in > /usr/include? You can post an issue at http://bugs.python.org Regards Antoine. -- http://m

Re: CGI python 3 write RAW BINARY

2010-04-30 Thread Antoine Pitrou
Le Thu, 29 Apr 2010 23:37:32 +0200, Dodo a écrit : > I don't get a thing. > Now with the fix : > All browsers shows a different thing, but not the image! > http://ddclermont.homeip.net/misc/python/ > > If I save it to computer : > * Windows image viewer won't read it > * Irfanview can read it

Re: CGI python 3 write RAW BINARY

2010-04-29 Thread Antoine Pitrou
Le Thu, 29 Apr 2010 18:33:08 +0200, Dodo a écrit : > Oh, I tested on my windows machine avec sys.stdout.buffer.write() didn't > work. > I just tested on my linux server, and it works > > So, let's modify the script > > sys.stdout.buffer.write( f.read() ) > sys.stdo

Re: CGI python 3 write RAW BINARY

2010-04-29 Thread Antoine Pitrou
Le Thu, 29 Apr 2010 12:53:53 +0200, Dodo a écrit : > > @Antoine : It not sys.stdout.buffer.write but sys.stdout.write() > instead. But it still doesn't work, now I have empty content Let me insist: please use sys.stdout.buffer.write(). You'll also have to call sys.stdout.flush() before doing so.

Re: CGI python 3 write RAW BINARY

2010-04-28 Thread Antoine Pitrou
Le Wed, 28 Apr 2010 23:54:07 +0200, Dodo a écrit : > Help! this is driving me crazy lol > I want to print raw binary data to display an image file BUT > python3 outputs b'' instead of so the > browser can't read the image!! > > f = open("/some/path/%s" % x, 'rb') > print(f.read()) print

<    1   2   3   >