numba 0.10
Numba 0.10 has some new interesting features, thanks to some new contributors. In short, it has a code annotation tool, builtins min, max, enumerate and zip, a parallel range (open sourced from numbapro) and support for the raise statement. Many thanks to Eugene Toder, Jay Bourque and Björn Linse. Version 0.10 == * Annotation tool (./bin/numba --annotate --fancy) (thanks to Jay Bourque) * Open sourced prange * Support for raise statement * Pluggable array representation * Support for enumerate and zip (thanks to Eugene Toder) * Better string formatting support (thanks to Eugene Toder) * Builtins min(), max() and bool() (thanks to Eugene Toder) * Fix some code reloading issues (thanks to Björn Linse) * Recognize NumPy scalar objects (thanks to Björn Linse) Download http://numba.pydata.org/download.html Website === http://numba.pydata.org/ Documentation http://numba.pydata.org/numba-doc/0.10/index.html Numba == Numba is an just-in-time specializing compiler which compiles annotated Python and NumPy code to LLVM (through decorators). Its goal is to seamlessly integrate with the Python scientific software stack and produce optimized native code, as well as integrate with native foreign languages. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
NuoDB's Python Driver now out of Beta with 1.2 Release
As NuoDB announces the 1.2 Release today: http://bit.ly/187MJYX, the Python Driver is moved out of Beta. As a bit of background information, NuoDB is a distributed Database that can be deployed in any datacenter, in any cloud, anywhere, without the compromises inherent in other NewSQL solutions. More details on how to configure the Python Driver can be found here: http://doc.nuodb.com/pages/viewpage.action?pageId=9896694 . Thanks for your time! Sincerely, Lindsey -- Lindsey Hoyem Community Manager *www.nuodb.com* http://www.nuodb.com/ p: 617-500-0001 t: @nuodb https://twitter.com/nuodb f: *facebook.com/NUODB https://www.facebook.com/NUODB* -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: Is it possible to make a unittest decorator to rename a method from x to testx?
adam.pre...@gmail.com wrote: On Thursday, August 8, 2013 3:50:47 AM UTC-5, Peter Otten wrote: Peter Otten wrote: Oops, that's an odd class name. Fixing the name clash in Types.__new__() is left as an exercise... Interesting, I got __main__.T, even though I pretty much just tried your code wholesale. I see I have to fix it myself then... For what it's worth, I'm using Python 2.7. I'm glad to see that code since I learned a lot of tricks from it. [My buggy code] class Type(type): def __new__(class_, name, bases, classdict): Here 'name' is the class name newclassdict = {} for name, attr in classdict.items(): if getattr(attr, test, False): assert not name.startswith(PREFIX) name = PREFIX + name assert name not in newclassdict newclassdict[name] = attr Here 'name' is the the last key of classdict which is passed to type.__new__ instead of the actual class name. return type.__new__(class_, name, bases, newclassdict) [Fixed version] class Type(type): def __new__(class_, classname, bases, classdict): newclassdict = {} for name, attr in classdict.items(): if getattr(attr, test, False): assert not name.startswith(PREFIX) name = PREFIX + name assert name not in newclassdict newclassdict[name] = attr return type.__new__(class_, classname, bases, newclassdict) -- http://mail.python.org/mailman/listinfo/python-list
Re: To make simpleXMLRPC support multi-thread
Zhang JiaQiang zhangjiaqi...@gmail.com writes: I try to use simpleXMLRPC and support request multithreads ,used ThreadingMixIn. Why what I get from the console still blocking ? I am not sure - but, you fail to call the inherited __init__ method in your deriving class. This might things mess up. ... class ListDirRPCServer(ThreadingMixIn, SimpleXMLRPCServer): def __init__(self, ip, port): self.server = SimpleXMLRPCServer((ip, port), logRequests=True) self.server.register_function(list_contents) Usually, in a derived class's __init__ method, you should call the inherited __init__ method. -- http://mail.python.org/mailman/listinfo/python-list
Data transfer from Python CGI to javascript
I have written the following program #!c:\Python27\Python.exe import cgi, cgitb; import sys, serial cgitb.enable() ser = serial.Serial('COM27', 9600) myvar = ser.readline() print Content-type:text/html\n\n print html head title Real Time Temperature /title script type=text/javascript window.onload = startInterval; function startInterval() { setInterval(startTime();,1000); } function startTime(myvar) { document.getElementById('mine').innerHTML =Temperature +parseInt(myvar); } /script /head body h1Real Time Temperature:/h1 div id=mine/div /body/html It is giving an output of 'NaN' in the output. If the python program is run alone it is giving the correct output. Can anyone please help. Is it also possible to separate the python and the javascript to two different files. If so how will I get/transfer the data in/from HTML . Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner question (True False help)
Le jeudi 8 août 2013 22:29:00 UTC+2, Terry Reedy a écrit : On 8/8/2013 7:41 AM, Chris Angelico wrote: On Thu, Aug 8, 2013 at 7:20 AM, wxjmfa...@gmail.com wrote: def z2(): ... letters = 'abc' ... while True: ... c = input('letter: ') ... if c not in letters: ... print('end, fin, Schluss') ... break ... else: ... print('do stuff') Minor quibble: I don't like having a hard exit followed by an else. Whereas I tend to prefer to have the two alternatives cleanly marked as alternatives by both being indented the same. Many alternatives are not so trivial as the above. I remember reading one snippet in the CPython codebase where the 'else' was omitted and the if clause subdivided into about three paths. It took at least a minute to determine that all paths terminated in such a way that there really was an inplied else. How much easier it would have been to read the code if the author had explicitly types the 'else'. If the if branch will unconditionally quit the loop (with a break, here, but could also be a return, a thrown exception, etc etc), I would prefer to see the else removed and its code unindented one level. Maybe this is just personal preference, though, learned from assembly language programming where a block if looks something like this: ; if x == y: CMP x,y JNZ .else ; Code for x == y JMP .endif .else: ; Code for else .endif Putting an unconditional departure in the x == y branch makes the JMP .endif redundant. Python is not assembly ;-). 3.3 effectively ignores the extraneous 'else:'. Either way, if the condition is false, control jumps to the second print. For what little it matters, the bytecode is the same length. def f(): while True: if a: b = 1 break else: b = 2 dis(f) 2 0 SETUP_LOOP 25 (to 28) 3 3 LOAD_GLOBAL 0 (a) 6 POP_JUMP_IF_FALSE 19 4 9 LOAD_CONST 1 (1) 12 STORE_FAST 0 (b) 5 15 BREAK_LOOP 16 JUMP_ABSOLUTE3 719 LOAD_CONST 2 (2) 22 STORE_FAST 0 (b) 25 JUMP_ABSOLUTE3 28 LOAD_CONST 0 (None) 31 RETURN_VALUE def f(): while True: if a: b = 1 break b = 2 dis(f) 2 0 SETUP_LOOP 25 (to 28) 3 3 LOAD_GLOBAL 0 (a) 6 POP_JUMP_IF_FALSE 19 4 9 LOAD_CONST 1 (1) 12 STORE_FAST 0 (b) 5 15 BREAK_LOOP 16 JUMP_FORWARD 0 (to 19) 619 LOAD_CONST 2 (2) 22 STORE_FAST 0 (b) 25 JUMP_ABSOLUTE3 28 LOAD_CONST 0 (None) 31 RETURN_VALUE -- Terry Jan Reedy - The problem of this guy is not at this level. His problem is more simply, he most probably does not understand how to build a correct, proper loop. What I wanted to happen is when the user typed something ... ... would cause the program to stop ... jmf -- http://mail.python.org/mailman/listinfo/python-list
connection change
Hi, I have a compiled code, which currently uses SQLITE connection (datastore). I was wondering if it is possible to change the connection string to use SQL Server database. I would like to export the datastore to SQL server database, as we are having issues with the sqlite limit. Thank you. Inna This email is intended solely for the named addressee. If you are not the addressee indicated please delete it immediately. -- http://mail.python.org/mailman/listinfo/python-list
Nested virtual environments
Dear all, is there a way to nest virtual environments? I work on several different projects that involve Python programming. For a lot of this projects I have to use the same packages (e.g. numpy, scipy, matplotlib and so on), while having to install packages that are specific for each project. For each of this project I created a virtual environment (using virtualenv --no-site-packages) and I had to reinstall the shared packages in each of them. I was wondering if there is a way to nest a virtual environment into another, so that I can create a common virtual environment that contains all the shared packages and then specialize the virtual environments installing the packages specific for each project. In a way this is not conceptually different to using virtualenv --system-site-packages, just instead of getting access to the system packages a virtual environment should be able to access the packages of an other one. Thanks a lot in advance for the help, Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: right adjusted strings containing umlauts
Le jeudi 8 août 2013 18:27:06 UTC+2, Kurt Mueller a écrit : Now I have this small example: -- #!/usr/bin/env python # vim: set fileencoding=utf-8 : from __future__ import print_function import sys, shlex print( repr( sys.stdin.encoding ) ) strg_form = u'{0:3} {1:3} {2:3} {3:3} {4:3}' for inpt_line in sys.stdin: proc_line = shlex.split( inpt_line, False, True, ) encoding = utf-8 proc_line = [ strg.decode( encoding ) for strg in proc_line ] print( strg_form.format( *proc_line ) ) -- $ echo -e a b c d e\na ö u 1 2 | file - /dev/stdin: UTF-8 Unicode text $ echo -e a b c d e\na ö u 1 2 | ./align_compact.py None a b c d e a ö u 1 2 $ echo -e a b c d e\na ö u 1 2 | recode utf8..latin9 | file - /dev/stdin: ISO-8859 text $ echo -e a b c d e\na ö u 1 2 | recode utf8..latin9 | ./align_compact.py None a b c d e Traceback (most recent call last): File ./align_compact.py, line 13, in module proc_line = [ strg.decode( encoding ) for strg in proc_line ] File /usr/lib64/python2.7/encodings/utf_8.py, line 16, in decode return codecs.utf_8_decode(input, errors, True) UnicodeDecodeError: 'utf8' codec can't decode byte 0xf6 in position 0: invalid start byte muk@mcp20:/sw/prog/scripts/text_manip How do I handle this two inputs? TIA -- Kurt Mueller It's very easy. The error msg indicates, you cann't decode your series of bytes with the utf-8 codec, simply because your string is encoded in iso-8859-* (you did it explicitly!). Your problem is not Python, your problem is the coding of the characters. You should be aware about the coding of the strings you are manipulating (creating) and if necessary decode and/or encode correctly accordingly to what you wish, eg. a suitable coding for the display. That's on this level that Python (or any language) matters. The sys.std*.encoding is a different problem. iso-8859-* ? iso-8859-1 == latin-1 and latin9 == iso-8859-15. If one excepts das grosse Eszett, both codings are able to handle German (it seems to be your case) and there are no problems when working directly with these codings. jmf -- http://mail.python.org/mailman/listinfo/python-list
Re: passing Python data to a javascript function
On Thursday, October 27, 2011 9:25:28 AM UTC+5:30, Chris Angelico wrote: On Thu, Oct 27, 2011 at 2:51 PM, Bill Allen walle...@gmail.com wrote: Chris, Wow, that seems so simple now that I see it. I was dancing around that all day, but just not landing on it. Thanks so very much for the assist. This code is giving an error 500 when run. Although the python code is independently running OK --Bill Final code that works perfectly, passes the value from the Python script to the javascript correctly: body onload=showPID(+pid_data+) Congratulations! You've just written code that writes code. It takes a bit to get your head around it (especially when you start worrying about literal strings that might contain quotes, for instance), but it's really cool and seriously powerful stuff. Your server-side Python code can generate client-side Javascript code any way it likes... unlimited possibilities. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Using sudo to write to a file as root from a script
Am 09.08.2013 05:47, schrieb David: On 9 August 2013 14:11, Adam Mercer ramer...@gmail.com wrote: I'm trying to write a script that writes some content to a file root through sudo, but it's not working at all. I am using: [...] At a quick glance, I have a couple of suggestions. command = ['echo', '-n', channel, '|', 'sudo', 'tee', config_file] sudo doesn't work like this. It doesn't read from standard input. You need to supply the command as an argument to sudo. Get the sudo syntax correct by learning to use it in a shell (eg terminal running bash ) before trying to use it from python code. Also, I think that passing the pipe character '|' as an argument to Popen is not the correct way to use pipes. So, if you figure out how to use sudo without '|' you will solve both these issues. Or try to change the permissions os.system(chmod 666 config_file) do what you want with the file and set the permissions back to their original state. -- http://mail.python.org/mailman/listinfo/python-list
Re: Using sudo to write to a file as root from a script
On Thu, Aug 8, 2013 at 11:47 PM, David bouncingc...@gmail.com wrote: At a quick glance, I have a couple of suggestions. command = ['echo', '-n', channel, '|', 'sudo', 'tee', config_file] sudo doesn't work like this. It doesn't read from standard input. You need to supply the command as an argument to sudo. Get the sudo syntax correct by learning to use it in a shell (eg terminal running bash ) before trying to use it from python code. The above does works in the terminal: [ram@cizin ~]$ ls -l /opt/ldg/etc/ total 20 -rw-rw-r-- 1 ram admin 5246 Jun 14 15:15 globus-user-env.csh -rw-rw-r-- 1 ram admin 3388 Jun 14 15:15 globus-user-env.sh -rw-rw-r-- 1 ram admin 91 Jun 24 11:33 ldg.conf -rw-r--r-- 1 ram admin5 Jun 14 15:24 os.conf $ echo -n stable | sudo tee /opt/ldg/etc/channel.conf /dev/null Password: $ ls -l /opt/ldg/etc/ total 24 -rw-r--r-- 1 root admin6 Aug 9 07:59 channel.conf -rw-rw-r-- 1 ram admin 5246 Jun 14 15:15 globus-user-env.csh -rw-rw-r-- 1 ram admin 3388 Jun 14 15:15 globus-user-env.sh -rw-rw-r-- 1 ram admin 91 Jun 24 11:33 ldg.conf -rw-r--r-- 1 ram admin5 Jun 14 15:24 os.conf $ Thats why I'm trying to use it. Also, I think that passing the pipe character '|' as an argument to Popen is not the correct way to use pipes. I believe subprocess uses pipes as follows import subprocess with open(/opt/ldg/etc/channel.conf,w) as out: subprocess.Popen(command, stdout=out) Then the file wouldn't be opened as root? And if the file already exists then I wouldn't be able to open it due to incorrect permissions. So, if you figure out how to use sudo without '|' you will solve both these issues. I'm open to suggestions as everything I can find involved pipes or redirections and neither seems to work with subprocess. I can use subprocess.call() as in: import subprocess import sys channel='stable' config_file='/opt/ldg/etc/channel.conf' command=echo -n %s | sudo tee %s /dev/null % (channel, config_file) try: retcode = subprocess.call(command, shell=True) if retcode 0: sys.exit('Error: Failed to set channel.conf') except OSError as e: sys.exit('Error: Execution failed %s' % e) But I was under the impression that Popen was the preferred approach to running external processes? Cheers Adam -- http://mail.python.org/mailman/listinfo/python-list
Re: Using sudo to write to a file as root from a script
On Fri, Aug 9, 2013 at 2:21 PM, Adam Mercer ramer...@gmail.com wrote: command=echo -n %s | sudo tee %s /dev/null % (channel, config_file) You shouldn't need to use 'echo' here. Just provide tee with the text on its standard input, and don't bother with the pipe at all. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Using sudo to write to a file as root from a script
Op 09-08-13 15:29, Chris Angelico schreef: On Fri, Aug 9, 2013 at 2:21 PM, Adam Mercer ramer...@gmail.com wrote: command=echo -n %s | sudo tee %s /dev/null % (channel, config_file) You shouldn't need to use 'echo' here. Just provide tee with the text on its standard input, and don't bother with the pipe at all. That is probably beside the point. I suspect Adam is just giving a minimal example to show the kind of thing he is trying to do. Nit picking the specific example instead of advising on the problem is likely to be less than helpful. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: Using sudo to write to a file as root from a script
On Fri, Aug 9, 2013 at 8:29 AM, Chris Angelico ros...@gmail.com wrote: You shouldn't need to use 'echo' here. Just provide tee with the text on its standard input, and don't bother with the pipe at all. Thanks, that's much better! Cheers Adam -- http://mail.python.org/mailman/listinfo/python-list
Re: Using sudo to write to a file as root from a script
On Fri, Aug 9, 2013 at 8:42 AM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: That is probably beside the point. I suspect Adam is just giving a minimal example to show the kind of thing he is trying to do. Nit picking the specific example instead of advising on the problem is likely to be less than helpful. It is a simplified example, but in this case the nitpicking was very helpful. Caused me to think about the problem differently, and therefore come up with a neater solution. Cheers Adam -- http://mail.python.org/mailman/listinfo/python-list
Re: Using sudo to write to a file as root from a script
Op 09-08-13 06:11, Adam Mercer schreef: Hi I'm trying to write a script that writes some content to a file root through sudo, but it's not working at all. I am using: channel = 'stable' config_file = '/opt/ldg/etc/channel.conf' command = ['echo', '-n', channel, '|', 'sudo', 'tee', config_file] p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, _ = p.communicate() But it seems as if this isn't doing anything. I just want to write the contents of the variable channel to the file /opt/ldg/etc/channel.conf. But whatever I try just doesn't work. Can anyone offer any pointers? Cheers Adam subprocess.Popen by default doesn't use a shell. That could mean that the equivallent shell command you are trying to execute is: echo -n stable '|' sudo tee /opt/ldg/etc/channel.conf instead of echo -n stable | sudo tee /opt/ldg/etc/channel.conf which you probably want. You should also take care with the echo command. Echo is usually a shell builtin that can behave differently than the echo command. You should make sure you are using the one you actually want to use. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: Using sudo to write to a file as root from a script
On Fri, Aug 9, 2013 at 2:50 PM, Adam Mercer ramer...@gmail.com wrote: On Fri, Aug 9, 2013 at 8:42 AM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: That is probably beside the point. I suspect Adam is just giving a minimal example to show the kind of thing he is trying to do. Nit picking the specific example instead of advising on the problem is likely to be less than helpful. It is a simplified example, but in this case the nitpicking was very helpful. Caused me to think about the problem differently, and therefore come up with a neater solution. It wasn't nitpicking so much as suggesting a more Pythonic way to do things. It's entirely plausible that the response would have been Actually, the real command is more complicated than 'echo' so I really do need a pipe, but it's *very* common in shell scripts to call on an external process to do something that in other languages is a builtin. For instance, how do you get the name of the parent of your current directory in bash? Something along the lines of: parent=$(dirname $(pwd$)$) which executes two external commands. In Python, it would be: os.path.dirname(os.getcwd()) which is two internal function calls. It's just one of the things to consider when porting code from one language to another - I wouldn't often use a list comprehension in bash, and I wouldn't often want a pipe between two external processes in Python. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Data transfer from Python CGI to javascript
On 09/08/2013 07:53, e...@cleantechsolution.in wrote: I have written the following program #!c:\Python27\Python.exe import cgi, cgitb; import sys, serial cgitb.enable() ser = serial.Serial('COM27', 9600) myvar = ser.readline() print Content-type:text/html\n\n print html head title Real Time Temperature /title script type=text/javascript window.onload = startInterval; function startInterval() { setInterval(startTime();,1000); } function startTime(myvar) { document.getElementById('mine').innerHTML =Temperature +parseInt(myvar); } /script /head body h1Real Time Temperature:/h1 div id=mine/div /body/html It is giving an output of 'NaN' in the output. If the python program is run alone it is giving the correct output. Can anyone please help. Is it also possible to separate the python and the javascript to two different files. If so how will I get/transfer the data in/from HTML . Thanks At a guess I'd say that it's because you have: setInterval(startTime();,1000); which will call 'startTime' with no arguments, but: function startTime(myvar) which means that it's expecting an argument. -- http://mail.python.org/mailman/listinfo/python-list
Re: Using sudo to write to a file as root from a script
On 9 August 2013 23:21, Adam Mercer ramer...@gmail.com wrote: On Thu, Aug 8, 2013 at 11:47 PM, David bouncingc...@gmail.com wrote: At a quick glance, I have a couple of suggestions. command = ['echo', '-n', channel, '|', 'sudo', 'tee', config_file] sudo doesn't work like this. It doesn't read from standard input. You need to supply the command as an argument to sudo. Get the sudo syntax correct by learning to use it in a shell (eg terminal running bash ) before trying to use it from python code. The above does works in the terminal: Ah, sorry, I didn't pay close attention to what you are doing (with tee). So, if you figure out how to use sudo without '|' you will solve both these issues. At least I wasn't 100% wrong :) Anyway I'm glad some smarter people helped you. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3 and SSH Tunnel
D. Xenakis schrieb: I've played with putty to achieve this but to be honest i'd like something more efficient. Opening putty everytime and making all the connection settings etc, and then running the programm, is kinda messy. Id like this to be done in an automatic way from the program so that things roll easy. I thought maybe i should find a way how to call and run a batch file from inside my python program or a powershell command, but i do not know even if that could work for the ssh tunneling. any ideas? Both popular frameworks for python SSH - twisted and paramiko - are still being ported to python3. If you need to run your code on Windows, take a look at plink, a command line tool for PuTTY: http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter7.html#plink You can wrap plink and your python script in a batch-file or call plink from inside your script using subprocess. -- http://mail.python.org/mailman/listinfo/python-list
Re: connection change
On Thu, Aug 8, 2013 at 10:23 PM, Inna Belakhova inna.belakh...@melbourne.vic.gov.au wrote: Hi, I have a compiled code, which currently uses SQLITE connection (datastore). I don't understand 'compiled code'. It would be nice if you show the code, give the version of python you are using, and the operating system Have you tried to change your program to use mysql instead? If so, show the changes you made and what the results were. I was wondering if it is possible to change the connection string to use SQL Server database. yes it is possible I would like to export the datastore to SQL server database, as we are having issues with the sqlite limit. Thank you. Inna This email is intended solely for the named addressee. If you are not the addressee indicated please delete it immediately. -- http://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com -- http://mail.python.org/mailman/listinfo/python-list
Python3 Multiprocessing
Aloha! I need a command that will make threads created by multiprocessing.Process() wait for each other to complete. For instance, I want to do something like this: job1 = multiprocessing.Process(CMD1()) job2 = multiprocessing.Process(CMD2()) jobs1.start(); jobs2.start() PY_FUNC() The command PY_FUNC() depends on the end result of the actions of CMD1() and CMD2(). I need some kind of wait command for the two threads that will not let the script continue until job1 and job2 are complete. Is this possible in Python3? Mahalo, devyncjohn...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python3 Multiprocessing
On 09/08/2013 20:30, Devyn Collier Johnson wrote: Aloha! I need a command that will make threads created by multiprocessing.Process() wait for each other to complete. For instance, I want to do something like this: job1 = multiprocessing.Process(CMD1()) job2 = multiprocessing.Process(CMD2()) jobs1.start(); jobs2.start() PY_FUNC() The command PY_FUNC() depends on the end result of the actions of CMD1() and CMD2(). I need some kind of wait command for the two threads that will not let the script continue until job1 and job2 are complete. Is this possible in Python3? Possibly you mean .join: jobs1.start() jobs2.start() jobs1.join() jobs2.join() -- http://mail.python.org/mailman/listinfo/python-list
Re: Using sudo to write to a file as root from a script
On Thu, 08 Aug 2013 23:11:09 -0500, Adam Mercer wrote: I'm trying to write a script that writes some content to a file root through sudo, but it's not working at all. I am using: command = ['echo', '-n', channel, '|', 'sudo', 'tee', config_file] You can't create a pipeline like this. All of the list elements after the first will be passed as arguments to echo. Try: command = ['sudo', 'tee', config_file] p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, _ = p.communicate('channel') -- http://mail.python.org/mailman/listinfo/python-list
Re: Using sudo to write to a file as root from a script
On Fri, 09 Aug 2013 21:12:20 +0100, Nobody wrote: Try: command = ['sudo', 'tee', config_file] p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, _ = p.communicate('channel') Oops; you also need stdin=subprocess.PIPE. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python3 Multiprocessing
On 08/09/2013 03:44 PM, MRAB wrote: On 09/08/2013 20:30, Devyn Collier Johnson wrote: Aloha! I need a command that will make threads created by multiprocessing.Process() wait for each other to complete. For instance, I want to do something like this: job1 = multiprocessing.Process(CMD1()) job2 = multiprocessing.Process(CMD2()) jobs1.start(); jobs2.start() PY_FUNC() The command PY_FUNC() depends on the end result of the actions of CMD1() and CMD2(). I need some kind of wait command for the two threads that will not let the script continue until job1 and job2 are complete. Is this possible in Python3? Possibly you mean .join: jobs1.start() jobs2.start() jobs1.join() jobs2.join() Thanks MRAB! That is easy. I always (incorrectly) thought the join() command got two threads and made them one. I did not know it made the script wait for the threads. Mahalo, devyncjohn...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python3 Multiprocessing
On Fri, Aug 9, 2013, at 16:43, Devyn Collier Johnson wrote: Thanks MRAB! That is easy. I always (incorrectly) thought the join() command got two threads and made them one. I did not know it made the script wait for the threads. What you're missing is the fact that the main thread [i.e. the one running the script, and that waits for the thread you call the method on] is, well, a thread. So, you start with two threads [the main thread and the jobs1 thread, for example], and end up with one [the main thread]. This is why it's called join. -- http://mail.python.org/mailman/listinfo/python-list
RE: Python3 Multiprocessing
Devyn Collier Johnson On 08/09/2013 03:44 PM, MRAB wrote: On 09/08/2013 20:30, Devyn Collier Johnson wrote: [snip] jobs1.join() jobs2.join() Thanks MRAB! That is easy. I always (incorrectly) thought the join() command got two threads and made them one. I did not know it made the script wait for the threads. It does join two threads, just not the threads you think! It joins a child thread with the parent thread and not two children thread. Mahalo, devyncjohn...@gmail.com -- ~Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner question (True False help)
This is what I ended up with btw. Does this insult anyone's more well attuned Python sensibilities? letters='abcdefghijkl' def repeat(): print('wanna go again?') batman=input() if batman in ('y','yes'): main() else: return def main(): print('guess a letter') batman=input() if batman in letters: print('ok that letter was in letters') repeat() else: print('asdasdasd') repeat() main() print('how ya doin') -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner question (True False help)
This is what I ended up with btw. Does this insult anyone's more well-attuned Pythonic sensibilities? letters='abcdefghijkl' def repeat(): print('wanna go again?') batman=input() if batman in ('y','yes'): main() else: return def main(): print('guess a letter') batman=input() if batman in letters: print('ok that letter was in letters') repeat() else: print('asdasdasd') repeat() main() print('how ya doin') -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner question (True False help)
On 9 August 2013 23:27, eschneide...@comcast.net wrote: This is what I ended up with btw. Does this insult anyone's more well attuned Python sensibilities? ... Yes. You didn't listen to any of the advice we've been giving you. You've had *much* better answers given than this. Start from the top. We need letters, so define that: letters = abcdefghijkl We then want to loop, possibly forever. A good choice is a while loop. # True is always True, so will loop forever while True: We then want to ask for a letter. We want to use input. Write help(input) in the Python Shell and you get help(input) Help on built-in function input in module builtins: input(...) input([prompt]) - string Read a string from standard input. The trailing newline is stripped. If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError. On Unix, GNU readline is used if enabled. The prompt string, if given, is printed without a trailing newline before reading. So our line should be: letter = input(Type a letter from 'a' to 'n' in the alphabet: ) Then we want to test if it's on of our letters: if letter in letters: And if so we want to say something positive: print(That's right.) If not we want to say something negative: else: print(That's wrong.) And then we want to ask if we should go again: go_again = input(Do you want to do this again? ) If the response is y or yes, we want to continue looping. The while loop will do that automatically, so we can do nothing in this circumstance. If the response in *not* y or yes, we want to stop: if go_again not in (y, yes): break That's it. No need to complicate things. Just take it one step at a time. -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner question (True False help)
I don't understand any of the advice any of you have given. -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner question (True False help)
Thanks, though me not utilizing any of the other advice wasn't from lack of trying; I couldn't understand any of it. I get it now that I have a corrrect example code in front of me. -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner question (True False help)
On 10 August 2013 00:14, eschneide...@comcast.net wrote: I don't understand any of the advice any of you have given. What about it don't you understand? Pick a sentence you don't understand and throw it back at us. If you understand all the sentences but not how they come together, say so. If there's a leap that you don't understand, say that you don't get it. We've tried rephrasing things a few ways but without any interaction we can't really help. --- You have said I figured that ... the batman==False part of the repeat() function would cause the 'while batman==True' part to become False and end. We have said this is untrue. The batman = False inside the function does not affect batman outside of the function. You need to put global batman in the function for it to change batman on a global scope. You've not once explained what part of this explanation confuses you. -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner question (True False help)
What does global mean? -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner question (True False help)
(I forgot to post this with my last post.) Also, I don't understand any part of the following example, so there's no specific line that's confusing me. Thanks for the help btw. var = 42 def myfunc(): var = 90 print before:, var myfunc() print after:, var def myfunc(): global var var = 90 -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner question (True False help)
(I forgot to post this with my last post.) Also, I don't understand any part of the following example, so there's no specific line that's confusing me. Thanks for the help btw. var = 42 def myfunc(): var = 90 print before:, var myfunc() print after:, var def myfunc(): global var var = 90 -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner question (True False help)
On 10/08/2013 00:40, eschneide...@comcast.net wrote: (I forgot to post this with my last post.) Also, I don't understand any part of the following example, so there's no specific line that's confusing me. Thanks for the help btw. You don't understand _any_ of it? var = 42 Here you're assigning to 'var'. You're not in a function, so 'var' is a global variable. def myfunc(): var = 90 Here you're assigning to 'var'. If you assign to a variable anywhere in a function, and you don't say that that variable is global, then it's treated as being local to that function, and completely unrelated to any other variable outside that function. print before:, var myfunc() print after:, var def myfunc(): global var var = 90 Here you're assigning to 'var', but this time you've declared that it's global, so you're assigning to the global variable called 'var'. -- http://mail.python.org/mailman/listinfo/python-list
Re: Simulate `bash` behaviour using Python and named pipes.
Luca Cerone wrote: Thanks! I managed to make it work using the threading library :) If at least one of the external programs can accept the source or destination as a filename argument instead of redirecting its stdin or stdout, you can also do something like this: import subprocess p2 = subprocess.Popen([cat, named_pipe]) pipe = open(named_pipe, w) p1 = subprocess.Popen([ls, -lah], stdout = pipe) pipe.close() p1.wait() p2.wait() That works because opening the reading end of the pipe is done by the subprocess executing cat, leaving the main process free to open the other end. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner question (True False help)
I'm sorry, but I still don't understand how it applies to my problem. Thanks for everyone's patience. -- http://mail.python.org/mailman/listinfo/python-list
PEP 450 Adding a statistics module to Python
I am seeking comments on PEP 450, Adding a statistics module to Python's standard library: http://www.python.org/dev/peps/pep-0450/ Please read the FAQs before asking anything :-) Also relevant: http://bugs.python.org/issue18606 -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner question (True False help)
On 10 August 2013 00:34, eschneide...@comcast.net wrote: What does global mean? Python has scopes for its variables. Most programming languages do. A scope is a restriction on where variables exist -- they exist only within the scope. This can be seen in this example: def function(): # A new scope is made when you enter a function variable = 100 function() print(variable) # Error, as variable doesn't exist outside of function's scope There are lots of different scopes in code. Every function has one, and there are some more too. One of the scopes is the global scope. This is the scope *outside* of all the functions and other scopes. Everything in the file is within this sope: # Make in global scope variable = 100 def function(): # Works because we're inside the global scope print(variable) # Prints 100 function() So a = b inside the function applies to the function's scope, but when accessing variables (such as print(variable)) it will look in all of the outer scopes too. If you want to write a = b inside the function and change the global scope, you need to say that a refers to the a in the global scope. You do that like this: def function(): # variable is in the global scope, not the functions' global variable variable = 100 function() # Prints 100 print(variable) Does that help you understand what global means? -- http://mail.python.org/mailman/listinfo/python-list
Re: right adjusted strings containing umlauts
On Thu, 08 Aug 2013 17:24:49 +0200, Kurt Mueller wrote: What do I do, when input_strings/output_list has other codings like iso-8859-1? When reading from a text file, honour some sort of encoding cookie at the top (or bottom) of the file, like Emacs and Vim use, or a BOM. If there is no encoding cookie, assume UTF-8. When reading from stdin, assume UTF-8. Otherwise, make it the caller's responsibility to specify the encoding if they wish to use something else. Pseudo-code: encoding = None if command line arguments include '--encoding': encoding = --encoding argument if encoding is None: if input file is stdin: encoding = 'utf-8' else: open file as binary if first 2-4 bytes look like a BOM: encoding = one of UTF-8 or UTF-16 or UTF-32 else: read first two lines if either looks like an encoding cookie: encoding = cookie # optionally check the end of the file as well close file if encoding is None: encoding = 'utf-8' read from file using encoding -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner question (True False help)
On Fri, 09 Aug 2013 16:34:48 -0700, eschneider92 wrote: What does global mean? Hi eschneider92, A few bits of advice: - You may like to actually sign your emails with a real name, or at least an alias that you want to be called, otherwise we'll just call you by your email address, and apart from sounding silly, many people don't like that. - You might also find that the tutor mailing list is a better match for your status as a complete beginner to Python. You can subscribe to it here: http://mail.python.org/mailman/listinfo/tutor - If you do, please take my advice and use individual emails, not daily digests. It is MUCH easier to carry on a back-and-forth conversation with individual emails. - Please try to quote enough of the message you are replying to to establish context, but without filling the email with page after page of irrelevant history. (Notice the line at the top of this message, starting with ? That's what you previously wrote.) If you need help configuring your email program to quote the previous message, just ask. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 450 Adding a statistics module to Python
On Fri, Aug 9, 2013 at 8:10 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I am seeking comments on PEP 450, Adding a statistics module to Python's standard library: http://www.python.org/dev/peps/pep-0450/ Please read the FAQs before asking anything :-) Given that installing numpy or scipy is generally no more difficult that executing pip install (scipy|numpy) I'm not really feeling the need for a battery here... (Of course, I use this stuff at work from time-to-time, so maybe I'm more in the nuclear reactor of batteries camp anyway.) Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: connection change
On Fri, Aug 9, 2013 at 7:31 PM, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Fri, 9 Aug 2013 14:36:54 -0400, Joel Goldstick joel.goldst...@gmail.com declaimed the following: Have you tried to change your program to use mysql instead? If so, show the changes you made and what the results were. Pardon? mssql is not the same as mysql oops.. bad reading Dennis.. -- Wulfraed Dennis Lee Bieber AF6VN wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/ -- http://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 450 Adding a statistics module to Python
Skip Montanaro s...@pobox.com writes: Given that installing numpy or scipy is generally no more difficult that executing pip install (scipy|numpy) I'm not really feeling the need for a battery here... NumPy and SciPy are not available for many Python users, including those using a Python implementation for which there is no Numpy support URL:http://new.scipy.org/faq.html#python-version-support and those for whom large, dependency-heavy third-party packages are too much burden. See the Rationale of PEP 450 for more reasons why “install NumPy” is not a feasible solution for many use cases, and why having ‘statistics’ as a pure-Python, standard-library package is desirable. -- \ “Dad always thought laughter was the best medicine, which I | `\guess is why several of us died of tuberculosis.” —Jack Handey | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
[issue13280] argparse should use the new Formatter class
Changes by paul j3 ajipa...@gmail.com: -- nosy: +paul.j3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13280 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18694] getxattr on Linux ZFS native filesystem happily returns partial values
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +benjamin.peterson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18694 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18690] memoryview not considered a sequence
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +mark.dickinson, skrah type: behavior - enhancement versions: -Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18690 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18685] Restore re performance to pre-PEP393 level
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +tim_one ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18685 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18226] IDLE Unit test for FormatParagrah.py
Terry J. Reedy added the comment: I got rid of the shutdown warning by replacing EditorWindow with a simple mock, as explained in the test file. Doing so also reduced the running time from about .40 seconds to .25 (it was 1.0+ before I reduced the redundancy of the tests). All the asserts passed after the substitution except for the last. For some reason, the 2nd line of the comment block looses its \n so that lines 2 and 3 get pasted together. I am baffled since the block is almost the same as the previous one. For the moment, I just commented out that test. -- Added file: http://bugs.python.org/file31204/18226FormatPara9.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18226 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18381] unittest warnings counter
Michael Foord added the comment: Looks good to me, except the backslash continuation is unneeded. Needs documentation. -- assignee: - michael.foord ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18381 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17974] Migrate unittest to argparse
Michael Foord added the comment: The patch looks like an improvement. Does it maintain the ability to pass the discovery arguments positionally and by keyword? If so then it can go in. I like the improved error reporting for nonsenical input to unittest.main. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17974 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17974] Migrate unittest to argparse
Serhiy Storchaka added the comment: Does it maintain the ability to pass the discovery arguments positionally and by keyword? Yes, of course. Only such command line are not supported more: ./python Lib/test/test_colorsys.py discover -v Lib/test/test_json/ or ./python -m test.test_colorsys discover -v Lib/test/test_json/ But this looks as an unintentional and senseless ability. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17974 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Stefan Behnel added the comment: Here is a patch that cleans up the current implementation to avoid making the result of iterparse() an IncrementalParser (with all of its new API). Please note that the tulip mailing list is not an appropriate place to discuss additions to the XML libraries, and ElementTree in particular. -- nosy: +scoder Added file: http://bugs.python.org/file31205/iterparse_cleanup.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18688] Document undocumented Unicode object API
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18688 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Changes by Stefan Behnel sco...@users.sourceforge.net: -- components: +XML ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Stefan Behnel added the comment: Copying the discussion between Antoine and me from python-dev: IMO it should mimic the interface of the TreeBuilder, which calls the data reception method feed() and the termination method close(). There is no reason to add yet another set of methods names just to do what others do already. Well, the difference here is that after calling eof_received() you can still (and should) call events() once to get the last events. I think it would be weird if you could still do something useful with the object after calling close(). Also, the method names are not invented, they mimick the PEP 3156 stream protocols: http://www.python.org/dev/peps/pep-3156/#stream-protocols I see your point about close(). I assume your reasoning was to make the IncrementalParser an arbitrary stream end-point. However, it doesn't really make all that much sense to connect an arbitrary data source to it, as the source wouldn't know that, in addition to passing in data, it would also have to ask for events from time to time. I mean, you could do it, but then it would just fill up the memory with parser events and loose the actual advantages of incremental parsing. So, in a way, the whole point of the class is to *not* be an arbitrary stream end-point. Anyway, given that there isn't really the One Obvious Way to do it, maybe you should just add a docstring to the class (ahem), reference the stream protocol as the base for its API, and then rename it to IncrementalStreamParser. That would at least make it clear why it doesn't really fit with the rest of the module API (which was designed some decade before PEP 3156) and instead uses its own naming scheme. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Stefan Behnel added the comment: Actually, let me take that last paragraph back. There is an Obvious Way to do it, and that's the feed() and close() methods. They are the existing and established ElementTree interface for incremental parsing. The fact that close() doesn't clean up all state is IMHO a minor issue. The state will be cleaned up automatically once the iteration terminates, and that's the normal behaviour of iterators. So it actually fits both protocols quite nicely. I'd just leave the stream protocol out completely here. For one, the implementation isn't complete anyway (the connection_*() methods don't make much sense), and as I said, it's not very useful to consider the parser a general end-point to that protocol. I'd also suggest returning the iterator over the remaining events from close(), just like the TreeBuilder returns the tree. That covers the (less common) use case of first parsing everything and then processing the events. I'll add another patch that does that. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Changes by Stefan Behnel sco...@users.sourceforge.net: Added file: http://bugs.python.org/file31206/iterparse_api_cleanup.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18606] Add statistics module to standard library
Oscar Benjamin added the comment: One small point: I think that the argument `m` to variance, pvariance, stdev and pstdev should be renamed to `mu` for pvariance/pstdev and `xbar` for variance/stdev. The doc-strings should carefully distinguish that `mu` is the true/population mean and `xbar` is the estimated/sample mean and refer to this difference between the function variants. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18606 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18695] os.statvfs() not working well with unicode paths
New submission from Giampaolo Rodola': From: https://code.google.com/p/psutil/issues/detail?id=416 # -*- coding: utf-8 -*- from __future__ import unicode_literals import os, errno name = ƒőő try: os.mkdir(name) except OSError as err: if err.errno != errno.EEXIST: raise os.statvfs(name) The script above works fine on Python 3.3 but on 2.7 you'll get: Traceback (most recent call last): File foo.py, line 10, in module os.statvfs(name) UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128) Patch in attachment fixes the issue. -- components: Unicode files: statvfs.patch keywords: needs review, patch messages: 194726 nosy: ezio.melotti, giampaolo.rodola priority: normal severity: normal status: open title: os.statvfs() not working well with unicode paths versions: Python 2.7 Added file: http://bugs.python.org/file31207/statvfs.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18695 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18685] Restore re performance to pre-PEP393 level
Antoine Pitrou added the comment: I get the same kind of results as Serhiy: $ python3.2 -m timeit -s import re; f = re.compile(b'abc').search; x = b'x'*10 f(x) 1 loops, best of 3: 81.7 usec per loop $ python3.2 -m timeit -s import re; f = re.compile('abc').search; x = 'x'*10 f(x) 1 loops, best of 3: 31.1 usec per loop $ python3.2 -m timeit -s import re; f = re.compile('abc').search; x = '\u20ac'*10 f(x) 1 loops, best of 3: 31.1 usec per loop Unpatched 3.4: $ ./python -m timeit -s import re; f = re.compile(b'abc').search; x = b'x'*10 f(x) 1 loops, best of 3: 81.6 usec per loop $ ./python -m timeit -s import re; f = re.compile('abc').search; x = 'x'*10 f(x) 1 loops, best of 3: 163 usec per loop $ ./python -m timeit -s import re; f = re.compile('abc').search; x = '\u20ac'*10 f(x) 1 loops, best of 3: 190 usec per loop Patched 3.4: $ ./python -m timeit -s import re; f = re.compile(b'abc').search; x = b'x'*10 f(x) 1 loops, best of 3: 54.4 usec per loop $ ./python -m timeit -s import re; f = re.compile('abc').search; x = 'x'*10 f(x) 1 loops, best of 3: 54.2 usec per loop $ ./python -m timeit -s import re; f = re.compile('abc').search; x = '\u20ac'*10 f(x) 1 loops, best of 3: 54.5 usec per loop -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18685 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Stefan Behnel added the comment: Thinking about the original patch some more - I wonder why it doesn't use a wrapper for TreeBuilder to process the events. Antoine, is there a reason why you had to add this _setevents() method to the XMLParser, instead of making the IncrementalParser an IncrementalTreeBuilder? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Stefan Behnel added the comment: Oh, and could we reopen this ticket, please? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Antoine Pitrou added the comment: Antoine, is there a reason why you had to add this _setevents() method to the XMLParser, instead of making the IncrementalParser an IncrementalTreeBuilder? The point is not to build a tree of potentially unbounded size (think XMPP). The point is to yield events in a non-blocking way (iterparse() is blocking, which makes it useless for non-blocking applications). An IncrementalTreeBuilder wouldn't have much point IMO. It is not more costly to accumulate a string and parse it at the end, than to progressively build a growing XML tree. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Changes by Antoine Pitrou pit...@free.fr: -- status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Antoine Pitrou added the comment: About the patch: I think changing the API names now that alpha1 has been released is a bit gratuitous. I would like to keep the encapsulation part but ditch the naming changes. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Stefan Behnel added the comment: The point is not to build a tree of potentially unbounded size (think XMPP). The point is to yield events in a non-blocking way (iterparse() is blocking, which makes it useless for non-blocking applications). Ok, but that's the only difference. Instead of getting the events from the parser, you could equally well get them from the TreeBuilder, also in a non-blocking way. Sticking this functionality into a parser target object has the advantage that the parser interface wouldn't have to change. So, instead of introducing an entirely new parser interface, we'd just add a class that can be used as a parser target and provides an additional events() method. That's a substantially less invasive API change. An IncrementalTreeBuilder wouldn't have much point IMO. It is not more costly to accumulate a string and parse it at the end, than to progressively build a growing XML tree. I don't think I understand what you mean. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Stefan Behnel added the comment: About the patch: I think changing the API names now that alpha1 has been released is a bit gratuitous. Sorry for being late, but I can't see it being my fault. A change in an alpha release is still way better than a change after a final release. Eventually, lxml will have to go on par here, so it's better to get it right now, before any harm is done. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Antoine Pitrou added the comment: The point is not to build a tree of potentially unbounded size (think XMPP). The point is to yield events in a non-blocking way (iterparse() is blocking, which makes it useless for non-blocking applications). Ok, but that's the only difference. Instead of getting the events from the parser, you could equally well get them from the TreeBuilder, also in a non-blocking way. But your TreeBuilder is also growing a tree internally, and therefore eating more and more memory, right? I don't see the point of stuffing different kinds of functionality inside a single class. It makes the intended use less obvious, and errors more likely. Right now, IncrementalParser has a simple API, and there's a single way to use it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Antoine Pitrou added the comment: A change in an alpha release is still way better than a change after a final release. But worse than no change at all. Arguing about API naming is a bit futile, *especially* when the ship has sailed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Stefan Behnel added the comment: But worse than no change at all. Arguing about API naming is a bit futile, *especially* when the ship has sailed. rantIt's easy to say that as a core developer with commit rights who can simply hide changes in a low frequented bug tracker without notifying those who have to know about these changes./rant It's pure luck I noticed this change during the alpha release cycle. I'm also not arguing about naming. I'm questioning the design, trying to get it into a shape that fits the existing APIs. Why do we need two incremental parsing interfaces in one and the same library that use completely different method names, although doing otherwise exactly the same? Why should the type of the *result* of the parsing process change the method name that you need to call to *insert* data into the parser? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Stefan Behnel added the comment: But IncrementalParser uses an XMLParser internally, which in turn uses a TreeBuilder internally. So what exactly is your point? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Antoine Pitrou added the comment: But IncrementalParser uses an XMLParser internally, which in turn uses a TreeBuilder internally. So what exactly is your point? Well, I would rather like to understand yours. Whatever IncrementalParser uses internally needn't impact what API it exposes to the user. (as a matter of fact, iterparse() doesn't expose a TreeBuilder-like API, either) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Stefan Behnel added the comment: Well, I would rather like to understand yours. My point is that the IncrementalParser uses a TreeBuilder that builds an XML tree in the back. So I'm wondering why you are saying that it doesn't build a tree. Whatever IncrementalParser uses internally needn't impact what API it exposes to the user. And in fact, we don't even need an IncrementalParser, because XMLParser already *has* an incremental parsing interface. All that's missing is the bit that collects and exposes the events. And my point is that we shouldn't duplicate the existing *data entry* interface for that, especially not under different names for identical functionality, but only add an interface to access those events as *output*, i.e. to add the bit of the API that's actually missing. As an analogon, what would you say if I asked for adding a new, separate Mapping interface to Python that uses the method name set_value() instead of __setitem__() because I want it to read data from the hard drive and not from memory? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Antoine Pitrou added the comment: rantIt's easy to say that as a core developer with commit rights who can simply hide changes in a low frequented bug tracker without notifying those who have to know about these changes./rant It's pure luck I noticed this change during the alpha release cycle. It is the rule for most stdlib improvements that they go directly through the bug tracker. Most core developers and outsiders would feel swamped by the traffic if all feature additions went through the mailing-list. I'm honestly baffled that you think I am trying to hide things. Why do you think I would feel guilty about proposing an addition, or try to sneak things inside xml.etree? (yes, we could theoretically run polls for every addition we propose, collect and discuss the results, and iterate several times until the outcome is successful; I don't think any of us has the bandwidth to do that, which is why that practice is only used for game-making changes (i.e. PEP material)) I'm also not arguing about naming. I'm questioning the design, trying to get it into a shape that fits the existing APIs. Why do we need two incremental parsing interfaces in one and the same library that use completely different method names, although doing otherwise exactly the same? Well, unless I'm missing something, TreeBuilder doesn't do parsing, it takes already parsed data: it has a start() method to open a tag, and a data() method to add raw text inside that tag. IncrementalParser, OTOH, has a data_received() method to which you pass a piece of non-parsed XML string. The other incremental parsing API is actually iterparse(). The reason I proposed IncrementalParser is that iterparse() is useless for non-blocking applications. IncrementalParser produces the same kind of output as iterparse(), but control of when to feed it data is transferred to the user of the API. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Stefan Behnel added the comment: TreeBuilder doesn't do parsing, it takes already parsed data: it has a start() method to open a tag, and a data() method to add raw text inside that tag. That is correct. However, the XMLParser has a feed() method that sends new data into the parser, and a close() method that tells the parser that it's done. So there already is an incremental parsing interface, and your change is duplicating that interface under a different name. Specifically, IncrementalParser has exactly the same interface as XMLParser when it comes to entering data, but uses different method names for it. This is a Bad Design because it introduces an unnecessary inconsistency in the API. However, what you are trying to change is not the way data is *entered* into the parser. What you are after is to change the way the *parsed* data is *presented* to the user. That is not the responsibility of the parser, it's the responsibility of the TreeBuilder. In your code, the TreeBuilder builds a tree, and the new interface *additionally* collects parse events in a list. So, the right way to do it would be to change the parser *target* to do both, i.e. to build a tree and collect events at the same time. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Antoine Pitrou added the comment: Well, I would rather like to understand yours. My point is that the IncrementalParser uses a TreeBuilder that builds an XML tree in the back. So I'm wondering why you are saying that it doesn't build a tree. Unless I'm reading it wrong, when _setevents() is called, the internal hooks are rewired to populate the events list, rather than call the corresponding TreeBuilder methods. So, yes, there's a TreeBuilder somewhere, but it stands unused. (the _setevents() method already existed on the C impl, by the way. I added it to the Python impl to make things more regular and avoid two separate iterparse() implementations) And my point is that we shouldn't duplicate the existing *data entry* interface for that, especially not under different names for identical functionality, but only add an interface to access those events as *output*, i.e. to add the bit of the API that's actually missing. What difference would that make? In the end, you mustn't mix event-driven/non-blocking and cumulative/blocking styles of programming, so having two separate APIs doesn't strike me as a problem (it may be a good thing actually, for clarity reasons). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Stefan Behnel added the comment: Unless I'm reading it wrong, when _setevents() is called, the internal hooks are rewired to populate the events list, rather than call the corresponding TreeBuilder methods. So, yes, there's a TreeBuilder somewhere, but it stands unused. Yes, you *are* reading it wrong. For example, the start callback calls self._start_list, which in turn calls self.target.start(), thus calling into the TreeBuilder. That's the thing that constructs the elements that the IncrementalParser collects in its events list. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Eli Bendersky added the comment: rantIt's easy to say that as a core developer with commit rights who can simply hide changes in a low frequented bug tracker without notifying those who have to know about these changes./rant It's pure luck I noticed this change during the alpha release cycle. What *are* you talking about? Who is trying to hide anything? Don't you see the history of the bug? Antoine opened it very... openly... and we discussed it. Also, committing to pre-alpha trunk is not a sailed ship - if there are problems, things can be easily fixed. Please stop complaining and learn to use the tools properly. Here's one tip: http://mail.python.org/mailman/listinfo/python-bugs-list - subscribe to it and use your mail client's filtering to see new bugs on topics that interest you. It isn't very hard. Another tip: http://mail.python.org/mailman/listinfo/python-checkins - subscribe to it and use your mail client's filtering to see new checkins on topics that interest you. It isn't hard either. Tip #3: ask to be added to the experts list for ET. No one would object to that, and it would increase the likelihood that people add you to the nosy list directly for ET-related issues (particularly added features). Now back to a productive discussion please... -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Stefan Behnel added the comment: ask to be added to the experts list for ET Already done, see the corresponding python-dev thread. Now back to a productive discussion please... I think we already are. Keep reading through the rest of the posts. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Eli Bendersky added the comment: On Fri, Aug 9, 2013 at 8:44 AM, Stefan Behnel rep...@bugs.python.orgwrote: Stefan Behnel added the comment: ask to be added to the experts list for ET Already done, see the corresponding python-dev thread. Done. 747970502b23 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Antoine Pitrou added the comment: Unless I'm reading it wrong, when _setevents() is called, the internal hooks are rewired to populate the events list, rather than call the corresponding TreeBuilder methods. So, yes, there's a TreeBuilder somewhere, but it stands unused. Yes, you *are* reading it wrong. For example, the start callback calls self._start_list, which in turn calls self.target.start(), thus calling into the TreeBuilder. That's the thing that constructs the elements that the IncrementalParser collects in its events list. Ah, indeed, my bad. That said, using a custom TreeBuilder-alike would necessitate changes in the C implementation of XMLParser. (which, I suppose, is why the _setevents hack exists in the first place) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18696] In unittest.TestCase.longMessage doc remove a redundant sentence
New submission from py.user: http://docs.python.org/3/library/unittest.html#unittest.TestCase.longMessage If set to True then any explicit failure message you pass in to the assert methods will be appended to the end of the normal failure message. The normal messages contain useful information about the objects involved, for example the message from assertEqual shows you the repr of the two unequal objects. Setting this attribute to True allows you to have a custom error message in addition to the normal one. the last sentence duplicates the first one -- assignee: docs@python components: Documentation files: issue.diff keywords: patch messages: 194748 nosy: docs@python, py.user priority: normal severity: normal status: open title: In unittest.TestCase.longMessage doc remove a redundant sentence type: enhancement versions: Python 3.3, Python 3.4 Added file: http://bugs.python.org/file31208/issue.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18696 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18685] Restore re performance to pre-PEP393 level
Matthew Barnett added the comment: @Antoine: Are you on the same OS as Serhiy? IIRC, wasn't the performance regression that wxjmfauth complained about in Python 3.3 apparent on Windows, but not on Linux? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18685 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18696] In unittest.TestCase.longMessage doc remove a redundant sentence
R. David Murray added the comment: I think the text is OK as it stands. The first sentence is a technical description of the result of setting the attribute, the last sentence is a conceptual discussion of why you would want to set the attribute. -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18696 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18670] Using read_mime_types function from mimetypes module gives resource warning
R. David Murray added the comment: Since the TESTFN file is created only in this test, rather than use a tearDown method, it would be better to use addCleanup in the test method itself. -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18670 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Stefan Behnel added the comment: Ok, finally. ;) Can we agree on discarding the current implementation for now and then rewriting it based on a tree builder instead of a parser wrapper? Because we'd need to change internal code is not a good argument for adding a new API, IMHO. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18655] GUI apps take long to launch on Windows
Terry J. Reedy added the comment: This tracker is for patching CPython, not Windows or 3rd-party C libraries. Ramchandra is right, Python does not display windows. In the cases you mention, this is done by 3-rd party cross-platform graphics libraries interacting with Windows' native graphics system. The fact that you have noticed the slow first launch with all 3 suggests that the problem is generic to Windows and how it initializes dlls that connect to Windows graphics system. I have the impression that this phenomenon is limited neither to Python nor to gui apps. One 'remedy' used by some apps is to load a 'quickstart' background process as part of startup. But that makes the boot or login process longer. In the absence of evidence that there is anything specifically wrong and fixable in CPython, I am closing this. Tim or Brian, if either of you think me mistaken, please re-open. -- nosy: +brian.curtin, terry.reedy, tim.golden resolution: - invalid stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18655 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Stefan Behnel added the comment: What about this idea: instead of changing the internal C implementation, we could provide a simple parser target wrapper class (say, EventBuilder) that the parser would simply recognise with isinstance(). Then it would unpack the wrapped target and configure itself as it currently does. So you'd use it like this: target = EventBuilder(TreeBuilder()) parser = XMLParser(target=target) parser.feed(some_xml_data) print list(target.events()) I mean, it doesn't really matter if the implementation is a fake, as long as the API is right. And the only API that the EventBuilder has is its events() method that returns the iterator. The EventBuilder implementation would then be class EventBuilder: def __init__(self, target=None): if target is None: target = TreeBuilder() self._target = target self._events = [] def events(self): # existing code for distructive iteration over self._events goes here ... and the rest would be done by the XMLParser() constructor, i.e. it would register the _events list in the expat callbacks. What do you think? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18697] Unify arguments names in Unicode object C API documentation
New submission from Serhiy Storchaka: In declarations of Unicode object C API functions in Doc/c-api/unicode.rst the first Unicode object argument has different names: unicode, str, u, s. It will be good to unify these names. Of course there is no need to change reasonable argument names for such functions as PyUnicode_Concat() or PyUnicode_CopyCharacters(). -- assignee: docs@python components: Documentation, Unicode keywords: easy messages: 194755 nosy: docs@python, ezio.melotti, haypo, serhiy.storchaka priority: normal severity: normal stage: needs patch status: open title: Unify arguments names in Unicode object C API documentation type: enhancement versions: Python 2.7, Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18697 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18688] Document undocumented Unicode object API
Serhiy Storchaka added the comment: It will be good first resolve issue18697. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18688 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18685] Restore re performance to pre-PEP393 level
Antoine Pitrou added the comment: @Antoine: Are you on the same OS as Serhiy? I don't know, I'm under Linux with gcc (on a x86-64 machine) :-) IIRC, wasn't the performance regression that wxjmfauth complained about in Python 3.3 apparent on Windows, but not on Linux? I don't know, but I'm not willing to give any attention to something reported by jmfauth. He's very far in the trollzone, as far as I'm concerned. However, if you are under Windows and can give it a try, it would be nice to have performance numbers for Serhiy's patch. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18685 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17741] event-driven XML parser
Antoine Pitrou added the comment: Can we agree on discarding the current implementation for now and then rewriting it based on a tree builder instead of a parser wrapper? Only if it actually brings something (feature-wise, performance-wise, maintenance-wise, whatever) that the current implementation doesn't have. Otherwise, I'd rather check in the simple inheritance-to-composition change. I'm sorry that you noticed this after the alpha. I would have had a lower threshold for changes if you had manifested when I proposed the feature. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18600] email.policy doc example passes 'policy' to as_string, but that doesn't work
R. David Murray added the comment: Turns out even with as_string accepting a policy keyword, the example still failed. It needs to be generating a bytes object, not a string. Before I even realized that, though, I decided I wanted to add as_bytes (and __bytes__). So the attached patch does that: adds policy to as_string, and adds new methods as_bytes and __bytes__ to Message. This patch is only for 3.4. The 3.3 patch will just delete that part of the policy example, so I'm not going to bother to upload it. -- keywords: +patch stage: needs patch - patch review Added file: http://bugs.python.org/file31209/as_string_policy.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18600 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18685] Restore re performance to pre-PEP393 level
Changes by STINNER Victor victor.stin...@gmail.com: -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18685 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18685] Restore re performance to pre-PEP393 level
Matthew Barnett added the comment: With the patch the results are: C:\Python34\python.exe -m timeit -s import re; f = re.compile(b'abc').search; x = b'x'*10 f(x) 1 loops, best of 3: 113 usec per loop C:\Python34\python.exe -m timeit -s import re; f = re.compile('abc').search; x = 'x'*10 f(x) 1 loops, best of 3: 113 usec per loop C:\Python34\python.exe -m timeit -s import re; f = re.compile('abc').search; x = '\u20ac'*10 f(x) 1 loops, best of 3: 113 usec per loop I'm most impressed! :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18685 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com