Re: Ordered dictionaries compared

2013-05-23 Thread Antoine Pitrou
Dan Stromberg gmail.com> writes: > > What kind of ordered dictionaries?  Sorted by key. Calling them "sorted dictionaries" avoids any confusions with Python's standard OrderedDict class: http://docs.python.org/3.3/library/collections.html#ordereddict-objects Regards Antoine. -- http://mail.

Re: usage of os.posix_fadvise

2013-05-29 Thread Antoine Pitrou
Hi, Wolfgang Maier biologie.uni-freiburg.de> writes: > > Dear all, > I was just experimenting for the first time with os.posix_fadvise(), which > is new in Python3.3 . I'm reading from a really huge file (several GB) and I > want to use the data only once, so I don't want OS-level page caching.

Re: Why is regex so slow?

2013-06-18 Thread Antoine Pitrou
Roy Smith panix.com> writes: > > Every line which contains 'ENQ' also matches the full regex (61425 > lines match, out of 2.1 million total). I don't understand why the > first way is so much slower. One invokes a fast special-purpose substring searching routine (the str.__contains__ operator),

Re: ssl handshake operation timed out on Python 3.3.2

2013-07-09 Thread Antoine Pitrou
Benedict Verheyen gmail.com> writes: > > Hi, > > for a project, I need to post data to some aspx pages. > The aspx pages are hosted by another company. > I develop on a virtual Debian Wheezy (Virtual box) running on Windows. > I couldn't get the code to run either on Windows nor Linux. > > On m

Re: Stack Overflow moderator “animuson”

2013-07-18 Thread Antoine Pitrou
Joshua Landau landau.ws> writes: > > > The same with Unicode. We hate French people, > > And for good damn reason too. They're ruining our language, á mon avis. We do! Regards Antoine. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why on CentOS, python consumes too much memory ?

2013-07-18 Thread Antoine Pitrou
gmail.com> writes: > > Hi: > >Previously, we found that our python scripts consume too much memory. So I use python's resource module to > restrict RLIMIT_AS's soft limit and hard limit to 200M. > On my RHEL5.3(i386)+python2.6.2, it works OK. But on CentOS 6.2(x86_64)+python2.6.6, it repor

Re: MyOpenID.com no longer supported

2013-07-29 Thread Antoine Pitrou
Le Mon, 29 Jul 2013 00:55:53 -0700, Ethan Furman a écrit : > Excerpt from http://meta.stackoverflow.com/q/190442/176681: > > Janrain no longer actively supports MyOpenID, and announced on > Twitter that their users should proceed with caution. > > This decision was made by Janrain, [snip] > > I

Re: Problem with psycopg2, bytea, and memoryview

2013-07-31 Thread Antoine Pitrou
Frank Millman chagford.com> writes: > > I have some binary data (a gzipped xml object) that I want to store in a > database. For PostgreSQL I use a column with datatype 'bytea', which is > their recommended way of storing binary strings. > > I use psycopg2 to access the database. It returns bi

Re: Problem with psycopg2, bytea, and memoryview

2013-07-31 Thread Antoine Pitrou
Frank Millman chagford.com> writes: > > Thanks for that, Antoine. It is an improvement over tobytes(), but i am > afraid it is still not ideal for my purposes. I would suggest asking the psycopg2 project why they made this choice, and if they would reconsider. Returning a memoryview doesn't mak

Re: append in IMAP4 from imaplib very slow

2012-07-25 Thread Antoine Pitrou
Simon Pirschel abusix.org> writes: > > Hi, > I'm currently experimenting with IMAP using Python 2.7.3 and IMAP4 > from imaplib. I noticed the performance to be very bad. I read 5000 > files from a directory and append them to an IMAP INBOX. The hole > procedure of reading and

Re: ssl: add msg_callback

2012-07-26 Thread Antoine Pitrou
Hi, Thiébaud Weksteen weksteen.fr> writes: > > I wrote a patch for Python 3.2.3 to expose the function > SSL_CTX_set_msg_callback in the module _ssl. > [...] > > Let me know your opinion on that. Does it worth being included? Yes, it sounds useful. Your patch will have to be written against

ANN: pathlib 0.7

2012-07-29 Thread Antoine Pitrou
bucket.org/pitrou/pathlib/ Regards Antoine Pitrou. -- Software development and contracting: http://pro.pitrou.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Flushing buffer on file copy on linux

2012-08-15 Thread Antoine Pitrou
J gmail.com> writes: > > Now, the problem I have is that linux tends to buffer data writes to a > device, and I want to work around that. When run in normal non-stress > mode, the program is slow enough that the linux buffers flush and put > the file on disk before the hash occurs. However, whe

Re: SSLSocket.getpeercert() doesn't return issuer, serial number, etc

2012-08-16 Thread Antoine Pitrou
Hello, Gustavo Baratto gmail.com> writes: > > SSL.Socket.getpeercert() doesn't return essential information present in the > client certificate (issuer, serial number, not before, etc), and it looks it > is > by design: It does, in Python 3.2: http://docs.python.org/py3k/library/ssl.html#clie

Re: Flexible string representation, unicode, typography, ...

2012-08-24 Thread Antoine Pitrou
Ramchandra Apte gmail.com> writes: > > The zen of python is simply a guideline What's more, the Zen guides the language's design, not its implementation. People who think CPython is a complicated implementation can take a look at PyPy :-) Regards Antoine. -- Software development and contr

Re: Flexible string representation, unicode, typography, ...

2012-08-30 Thread Antoine Pitrou
gmail.com> writes: > > Pick up a random text and see the probability this > text match the most optimized case 1 char / 1 byte, > practically never. Funny that you posted a text which does just that: http://mail.python.org/pipermail/python-list/2012-August/629554.html > In a funny way, this is

Re: Looking for an IPC solution

2012-08-31 Thread Antoine Pitrou
Laszlo Nagy shopzeus.com> writes: > > There are just so many IPC modules out there. I'm looking for a solution > for developing a new a multi-tier application. The core application will > be running on a single computer, so the IPC should be using shared > memory (or mmap) and have very short

Re: The opener parameter of Python 3 open() built-in

2012-09-05 Thread Antoine Pitrou
Chris Angelico gmail.com> writes: > > On Wed, Sep 5, 2012 at 5:16 AM, Terry Reedy udel.edu> wrote: > > io.open depends on a function the returns an open file descriptor. opener > > exposes that dependency so it can be replaced. > > I skimmed the bug report comments but didn't find an answer to

Re: Using Py_AddPendingCall

2012-09-17 Thread Antoine Pitrou
css322 gmail.com> writes: > > (1) A worker thread calls Py_AddPendingCall and assigns a handler function. > (2) When the Python interpreter runs, it calls the handler function whenever it yields control to another thread Not exactly. As the documentation says: "If successful, func will be called

Re: Posix call (execve) breaks mercurial?

2012-10-12 Thread Antoine Pitrou
Hello, Wayne Werner waynewerner.com> writes: > > So... curiouser and curiouser - it looks like it's not *actually* execve's > fault after all. I just compiled the code from the man page, tweaked it to > run 'hg root', and passed it a new environment. No problems. Well, then I > manually call

Re: deque and thread-safety

2012-10-12 Thread Antoine Pitrou
Hello, Christophe Vandeplas vandeplas.com> writes: > > From the documentation I understand that deques are thread-safe: > > Deques are a generalization of stacks and queues (the name is pronounced “deck” > > and is short for “double-ended queue”). Deques support thread-safe, memory > > efficie

Re: Memory profiling: Python 3.2

2012-11-02 Thread Antoine Pitrou
Andrew Robinson r3dsolutions.com> writes: > > When Python3.2 is running, is there an easy way within Python to capture > the *total* amount of heap space the program is actually using (eg:real > memory)? I'm not sure what you mean with "real memory" or how precise you want that measurement t

Re: Py3k Signal Handling

2012-11-10 Thread Antoine Pitrou
Jonathan Hayward pobox.com> writes: > > What needs changing here and how should I change it so that handle_signal() > is called and then things keep on ticking? So that it is called when exactly? Your message isn't clear as to what isn't working for you. Regards Antoine. -- http://mail.pyt

Re: Thought of the day

2013-01-15 Thread Antoine Pitrou
Steven D'Aprano pearwood.info> writes: > > A programmer had a problem, and thought Now he has "I know, I'll solve > two it with threads!" problems. Host: Last week the Royal Festival Hall saw the first performance of a new logfile by one of the world's leading modern programmers, Steven "Two t

Re: nested embedding of interpreter

2012-02-06 Thread Antoine Pitrou
Hello, Eric Frederich gmail.com> writes: > > 1)Is calling Py_Initialize twice correct, or will I run into other problems > down the road? It's fine in practice (spurious calls are ignored). > I am not sure if there is a mechanism to get something called at the end of the > user's session wit

Re: Simple TLS NPN negotiation not working on socket server

2012-04-18 Thread Antoine Pitrou
Alek Storm gmail.com> writes: > > Connecting with either Firefox 11 or Chrome (which both support NPN) causes > this to print None, rather than a protocol name. What's going on? Ok, I've just tried with Firefox 11. You have to go in "about:config" and set "network.http.spdy.enabled" to true. The

Re: Smallest/cheapest possible Python platform?

2012-05-26 Thread Antoine Pitrou
Roy Smith panix.com> writes: > > What's the smallest/cheapest/lowest-power hardware platform I can run > Python on today? I'm looking for something to use as a hardware > controller in a battery-powered device and want to avoid writing in C > for this project. It depends *which* Python. Comp

Re: [RELEASE] mpdecimal-2.5.0

2020-06-29 Thread Antoine Pitrou
Hi Stefan On Mon, 29 Jun 2020 15:27:01 +0200 Stefan Krah wrote: > Hi, > > I've released mpdecimal-2.5.0: > >http://www.bytereef.org/mpdecimal/index.html > > 15417edc8e12a57d1d9d75fa7e3f22b158a3b98f44db9d694cfd2acde8dfa0ca > mpdecimal-2.5.0.tar.gz > > Starting with Python 3.9, this ver

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): """

Re: Self-defence

2013-11-17 Thread Antoine Pitrou
Zero Piraeus etiol.net> writes: > > I don't believe that killfiles are a sufficient response in this > situation. > > I can, of course, stop Nikos' posts reaching me, and without too much > hassle also stop replies to his posts reaching me. He would, however, > continue to pollute the list in pu

ANN: pathlib 0.97 released

2013-12-10 Thread Antoine Pitrou
Hello, As you may know, pathlib has recently been accepted for inclusion into the Python 3.4 standard library. You can view the new module's documentation here: http://docs.python.org/dev/library/pathlib.html As part of the inclusion process, many API changes were done to the original pathlib A

Re: Blog "about python 3"

2013-12-31 Thread Antoine Pitrou
Steven D'Aprano pearwood.info> writes: > > I expect that as excuses for not migrating get fewer, and the deadline for > Python 2.7 end-of-life starts to loom closer, more and more haters^W > Concerned People will whine about the lack of version 2.8 and ask for > *somebody else* to fork Python. >

Re: Blog "about python 3"

2014-01-02 Thread Antoine Pitrou
Hi, Robin Becker reportlab.com> writes: > > For fairly sensible reasons we changed the internal default to use unicode > rather than bytes. After doing all that and making the tests compatible etc etc > I have a version which runs in both and passes all its tests. However, for > whatever rea

Re: "More About Unicode in Python 2 and 3"

2014-01-05 Thread Antoine Pitrou
On Sun, 05 Jan 2014 08:22:38 -0500 Ned Batchelder wrote: > On 1/5/14 8:14 AM, Mark Lawrence wrote: > > http://lucumr.pocoo.org/2014/1/5/unicode-in-2-and-3/ > > > > Please don't shoot the messenger :) > > > > With all of the talk about py 2 vs. py3 these days, this is the blog > post that I think

Re: "More About Unicode in Python 2 and 3"

2014-01-06 Thread Antoine Pitrou
Ned Batchelder nedbatchelder.com> writes: > > You can look through his problems and decide that he's "wrong," or that > he's "ranting," but that doesn't change the fact that Python 3 is > encountering friction. What happens when a significant fraction of your > customers are "wrong"? Well, y

Re: "More About Unicode in Python 2 and 3"

2014-01-06 Thread Antoine Pitrou
Chris Angelico gmail.com> writes: > > On Tue, Jan 7, 2014 at 3:29 AM, Antoine Pitrou pitrou.net> wrote: > > People don't use? According to available figures, there are more downloads of > > Python 3 than downloads of Python 2 (Windows installers, mostly): >

Re: "More About Unicode in Python 2 and 3"

2014-01-06 Thread Antoine Pitrou
Ned Batchelder nedbatchelder.com> writes: > > > I never said they were the whole community, of course. But they are not > outliers either. By your own statistics above, 23% of respondents think > Python 3 was a mistake. Armin and Kenneth are just two very visible > people. Indeed, they are

Re: "More About Unicode in Python 2 and 3"

2014-01-06 Thread Antoine Pitrou
Mark Lawrence yahoo.co.uk> writes: > [...] > > And as I started this thread, I'll say what I please, throwing my toys > out of my pram in just the same way that your pal Armin is currently doing. I'll join Ned here: please stop it. You are doing a disservice to everyone. Thanks in advance An

Re: "More About Unicode in Python 2 and 3"

2014-01-06 Thread Antoine Pitrou
Terry Reedy udel.edu> writes: > > On 1/6/2014 11:29 AM, Antoine Pitrou wrote: > > > People don't use? According to available figures, there are more downloads of > > Python 3 than downloads of Python 2 (Windows installers, mostly): > > http://www.python.org/we

Re: SQLite + FTS (full text search)

2014-01-23 Thread Antoine Pitrou
Hi, Mark Summerfield qtrac.plus.com> writes: > > My guess is that on Debian, the packagers install a full SQLite 3 and the Python package uses that. But on > Windows I think the Python packagers bundle their own SQLite (quite rightly since it might not already be installed). > > I'd like the W

Re: AssertionError (3.X only) when calling Py_Finalize with threads

2015-01-31 Thread Antoine Pitrou
Hi Tom, Tom Kent gmail.com> writes: > > I'm getting an error output when I call the C-API's Py_Finalize() from a different C-thread than I made a > python call on. Can you please post a bug on https://bugs.python.org ? Be sure to upload your example there. Thank you Antoine. -- https://ma

Re: which async framework?

2014-03-11 Thread Antoine Pitrou
Chris Withers simplistix.co.uk> writes: > > The protocols are all financial (do we really not have a pure-python FIX > library?!) but none are likely to have existing python implementations. If you are mostly writing protocol implementations (aka parsers and serializers), then you should consid

Re: which async framework?

2014-03-11 Thread Antoine Pitrou
Sturla Molden gmail.com> writes: > > Chris Withers simplistix.co.uk> wrote: > > Hi All, > > > > I see python now has a plethora of async frameworks and I need to try > > and pick one to use from: > > > > - asyncio/tulip > > - tornado > > - twisted > > I'd go for using iocp, epoll and kqueue/

Re: which async framework?

2014-03-11 Thread Antoine Pitrou
Sturla Molden gmail.com> writes: > > Antoine Pitrou pitrou.net> wrote: > > > Yes, why use a library when you can rewrite it all yourself? > > This assumes something equivalent to the library will have to be written. > But if it can be replaced with somethin

Re: What does gc.get_objects() return?

2014-03-17 Thread Antoine Pitrou
Chris Angelico gmail.com> writes: > > It's not strictly an implementation detail, beyond that there are > certain optimizations. For instance... > > > For CPython 3.4 I guess strings and other atomic types such as ints are > > not, as well as raw object() instances. Custom class instances on t

Re: Thread._stop() behavior changed in Python 3.4

2014-03-17 Thread Antoine Pitrou
Hi, Felix Yan gmail.com> writes: > > A minimized snippet to reproduce: > > #!/usr/bin/python > import threading > def stale(): > import time > time.sleep(1000) > t = threading.Thread(target=stale) > t.start() > t._stop() > > This works correctly with Python 3.3, the program exits imme

[ANN] pathlib 1.0

2014-03-25 Thread Antoine Pitrou
Hello, I am announcing the release of pathlib 1.0. This version brings pathlib up to date with the official Python 3.4 release, and also fixes a couple of 2.7-specific issues. Detailed changelog can be found further below. In the future, I expect the standalone (PyPI) version of pathlib to re

Re: [ANN] pathlib 1.0

2014-03-25 Thread Antoine Pitrou
Oh, and of course it is published on PyPI: https://pypi.python.org/pypi/pathlib/ Regards Antoine. -- https://mail.python.org/mailman/listinfo/python-list

Re: imaplib: how to specify SSL/TLS protocol version?

2014-04-10 Thread Antoine Pitrou
Grant Edwards invalid.invalid> writes: > > Experiments show that when calling ssl.wrap_socket() I have to specify > ssl_version=PROTOCOL_TLSv1 to avoid the above error. > > How do I tell imaplib to use TLS1 instead of SSL3? Use Python 3 and pass the ssl_context parameter to IMAP_SSL: https://do

Re: Everything you did not want to know about Unicode in Python 3

2014-05-16 Thread Antoine Pitrou
Terry Reedy udel.edu> writes: > > On 5/13/2014 8:53 PM, Ethan Furman wrote: > > On 05/13/2014 05:10 PM, Steven D'Aprano wrote: > >> On Tue, 13 May 2014 10:08:42 -0600, Ian Kelly wrote: > >> > >>> Because Python 3 presents stdin and stdout as text streams however, it > >>> makes them more difficul

Re: Pair of filenos read/write each other?

2013-08-14 Thread Antoine Pitrou
Nobody nowhere.com> writes: > > On Tue, 13 Aug 2013 16:10:41 -0700, Jack Bates wrote: > > > Is there anything like os.pipe() where you can read/write both ends? > > There's socket.socketpair(), but it's only available on Unix. > > Windows doesn't have AF_UNIX sockets, and anonymous pipes (like

Re: Pair of filenos read/write each other?

2013-08-15 Thread Antoine Pitrou
Jack Bates nottheoilrig.com> writes: > > > > An alternative is to use multiprocessing.Pipe(): > > http://docs.python.org/3.3/library/multiprocessing.html#multiprocessing.Pipe > > > > In any case, Python doesn't lack facilities for doing what you want. > > Thank you for your help, I need to sati

Re: [RELEASED] Python 3.4.0a2

2013-09-09 Thread Antoine Pitrou
Le Mon, 9 Sep 2013 08:16:06 -0400, Brett Cannon a écrit : > On Mon, Sep 9, 2013 at 8:02 AM, Larry Hastings > wrote: > > > > > On behalf of the Python development team, I'm chuffed to announce > > the second alpha release of Python 3.4. > > > > This is a preview release, and its use is not recomm

Re: [python-committers] [RELEASED] Python 3.4.0a2

2013-09-09 Thread Antoine Pitrou
Le Mon, 9 Sep 2013 14:30:50 +0200, Victor Stinner a écrit : > 2013/9/9 Larry Hastings : > > Python 3.4 includes a range of improvements of the 3.x series, > > including hundreds of small improvements and bug fixes. Major new > > features and changes in the 3.4 release series so far include: > > >

ANN: Obelus 0.1 -- Asterisk AMI / AGI implementation

2013-09-12 Thread Antoine Pitrou
Hello, I'm pleased to announce the first release of Obelus, a MIT-licensed library to interact with Asterisk using the AMI and AGI protocols. This is version 0.1, and as such some APIs are a bit draftish and not guaranteed to be stable accross future releases. Also, documentation is far from ex

Re: Tab completion in Python3.4

2013-09-30 Thread Antoine Pitrou
Steven D'Aprano pearwood.info> writes: > > I don't consider either of these solutions to be satisfactory. If you > agree, I urge you to try it out for yourself, and then leave a comment on > the bug tracker asking for tab completion to still insert tabs at the > beginning of the line: Such a

Re: Python Front-end to GCC

2013-10-22 Thread Antoine Pitrou
Philip Herron googlemail.com> writes: > > Its interesting a few things come up what about: > > exec and eval. I didn't really have a good answer for this at my talk at PYCon IE 2013 but i am going to say no. I am > not going to implement these. Partly because eval and exec at least to me are mos

Re: Python Front-end to GCC

2013-10-22 Thread Antoine Pitrou
Steven D'Aprano pearwood.info> writes: > > On Tue, 22 Oct 2013 08:55:15 +, Antoine Pitrou wrote: > > > If you don't implement exec() and eval() then people won't be able to > > use namedtuples, which are a common datatype factory. > > Philip

Re: Will Python 3.x ever become the actual standard?

2013-10-24 Thread Antoine Pitrou
> gmail.com> writes: > > I am starting to have doubts as to whether Python 3.x will ever be actually adopted by the Python community at > large as their standard. We're planning to start the switch on 25th December 2013, 14h UTC. It should be finished at most 48 hours later. You should expect so

[OT] Re: Python Front-end to GCC

2013-10-29 Thread Antoine Pitrou
Steven D'Aprano pearwood.info> writes: > > On Fri, 25 Oct 2013 21:36:42 +0100, Mark Lawrence wrote: > > > Mind you, the thought of a bot with a Ph.D. is mind boggling. > > You can buy degrees on the Internet quite cheaply: > > http://en.wikipedia.org/wiki/List_of_animals_with_fraudulent_diplom

[ANN] pathlib 1.0.1

2014-09-03 Thread Antoine Pitrou
Hello, I am announcing the release of pathlib 1.0.1. This version makes pathlib Python 2.6-compatible. Note that 2.6 compatibility may not have been as well tested as more recent Python versions (especially on non-Unix platforms). As a reminder, the standalone (PyPI) version of pathlib will no

Re: __qualname__ in python 3.3

2014-09-07 Thread Antoine Pitrou
Hi, ISE Development gmail.com> writes: > 'code' object 'function' object > > co_name: test __qualname__: test > co_name: T__qualname__: T > co_name: method __qualname__: test..T.method > > The second call corresponds to th

Re: weakref, memory management and execution slow down in PyQt4

2014-09-07 Thread Antoine Pitrou
kjs riseup.net> writes: > > I have come to believe that the growing number of weakrefs is slowing > down execution. Is my analysis misguided? How can I introspect further? > If the slowdown can be attributed to weakref escalation, what are some > next steps? The way to analyze this is to build s

Re: Newer Debian versions of python on older Debian distros?

2014-09-13 Thread Antoine Pitrou
Hi, Chris Angelico gmail.com> writes: > > On Tue, Sep 9, 2014 at 5:04 AM, Travis Griggs gmail.com> wrote: > > Does anyone have experience with using newer versions of python debian packages (in particular, python3 > and python3-bson-ext from ‘testing’) on older stable versions (‘wheezy’ in thi

Re: "High water" Memory fragmentation still a thing?

2014-10-03 Thread Antoine Pitrou
Hello, Croepha gmail.com> writes: > > Question: > > Does python in general terms (apart from extensions or gc manipulation), exhibit a "high water" type leak of allocated memory in recent python versions (2.7+)? It is not a leak. It is a quite common pattern of memory fragmentation. The artic

Re: "High water" Memory fragmentation still a thing?

2014-10-04 Thread Antoine Pitrou
Christian Heimes python.org> writes: > > The article doesn't state if the writer is referring to virtual memory > or resident set size. Actually the article mentions the following recipe: resource.getrusage(resource.RUSAGE_SELF).ru_maxrss which means the author is probably looking at residen

Re: Getting involved

2012-01-07 Thread Antoine Pitrou
Hello, Sophie Sperner gmail.com> writes: > > Let me ask here please. I'm a first-year PhD student in Ireland. My > background is in mathematics, though I'm going to stream my career > into programming with Python, Java and C++ languages. I have some good > experience with C++ what allowed me to

Re: IMAP4_SSL and OpenSSL compatibility

2013-02-26 Thread Antoine Pitrou
W. Martin Borgert debian.org> writes: > > When I add an ssl_version argument to the call to > ssl.wrap_socket() in imaplib.IMAP4_SSL.open(), I can connect to > the Exchange server without problems: > > self.sslobj = ssl.wrap_socket(self.sock, self.keyfile, self.certfile, >

Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Antoine Pitrou
Steven D'Aprano pearwood.info> writes: > > It is valuable to contrast and compare the PHP and Python docs: > > http://php.net/manual/en/index.php > http://www.python.org/doc/ I suppose you should compare it with http://docs.python.org/3/ instead. > There's no doubt that one of PHP's strengths,

Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Antoine Pitrou
Mitya Sirenef lightbird.net> writes: > I think the issue with python documentation is that it ignores the 95/5 > rule: 95% of people who land on a module's page are only looking for 5% > of its information. The 95/5 rule is generally a fallacy which ignores that the 5% which the readers are expec

Re: Writing to same file from two threads

2013-02-27 Thread Antoine Pitrou
Jens Thoms Toerring toerring.de> writes: > > Paul Rubin nospam.invalid> wrote: > > jt toerring.de (Jens Thoms Toerring) writes: > > > in garbled output (i.e. having some output from A inside a > > > line written by B or vice versae) because the "main thread" or > > > Yes they do get garbled li

Re: Writing to same file from two threads

2013-03-01 Thread Antoine Pitrou
Steven D'Aprano pearwood.info> writes: > > On Wed, 27 Feb 2013 13:26:18 +, Antoine Pitrou wrote: > > > For the record, binary files are thread-safe in Python 3, but text files > > are not. > > Where is this documented please? In the documentation, of c

Re: Speeding up Python's exit

2013-03-01 Thread Antoine Pitrou
Steven D'Aprano pearwood.info> writes: > > I just quit an interactive session using Python 2.7 on Linux. It took in > excess of twelve minutes to exit, with the load average going well past 9 > for much of that time. > > I think the reason it took so long was that Python was garbage-collecting

Re: IMAP4_SSL and OpenSSL compatibility

2013-03-01 Thread Antoine Pitrou
W. Martin Borgert debian.org> writes: > > > > There is already the ssl_context option for that: > > http://docs.python.org/3.3/library/imaplib.html#imaplib.IMAP4_SSL > > Many thanks! Two more questions: > > 1. Is there any plan to backport this Python >= 3.3 feature to > Python 2? No, we

Re: Speeding up Python's exit

2013-03-01 Thread Antoine Pitrou
Grant Edwards invalid.invalid> writes: > > > I assume that the memory used by the Python process will be reclaimed > > by the operating system, but other resources such as opened files may > > not be. > > All open files (including sockets, pipes, serial ports, etc) will be > flushed (from an OS

ANN: pathlib 0.8

2013-03-01 Thread Antoine Pitrou
pathlib 0.8 has been released at https://pypi.python.org/pypi/pathlib/ Changes --- - Add PurePath.name and PurePath.anchor. - Add Path.owner and Path.group. - Add Path.replace(). - Add Path.as_uri(). - Issue #10: when creating a file with Path.open(), don't set the executable bit. - Issue

Re: Speeding up Python's exit

2013-03-01 Thread Antoine Pitrou
Dave Angel davea.name> writes: > > Note he didn't say the python buffers would be flushed. It's the OS > buffers that are flushed. Now please read my message again. The OS buffers are *not* flushed according to POSIX. -- http://mail.python.org/mailman/listinfo/python-list

Re: standalone vs embedded interpreter

2013-04-09 Thread Antoine Pitrou
Nick Gnedin gmail.com> writes: > I expect it to behave the same way as if I was running it as a > standalone program. On Windows this is indeed the case, but on my Linux > box (Python 3.3.1 (default, Apr 8 2013, 22:33:31) [GCC 4.1.2 20080704 > (Red Hat 4.1.2-51)]) I get a different behavior in

Re: Unicode issue with Python v3.3

2013-04-10 Thread Antoine Pitrou
rusi gmail.com> writes: > > Hmm I see some cut-paste goofup on my part. > I was meaning to juxtapose this thread where we put up with inordinate > amount of nonsense from OP > along with the recent thread in which a newcomer who thinks he has > found a bug in pdb is made fun of. > > Then thought

Re: The node.js Community is Quietly Changing the Face of Open Source

2013-04-17 Thread Antoine Pitrou
rusi gmail.com> writes: > > Just what I said: ecosystem matters. We may or may not argue about > "more than language", but it surely matters. Some examples: > > 1. In the link that Roderick originally posted there is a long comment > that adds perl to the languages the author discussed. As a la

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

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: 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: 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
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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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-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: 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

  1   2   3   >