RE: How to write fast into a file in python?

2013-05-18 Thread Fábio Santos
On 17 May 2013 19:38, Carlos Nepomuceno carlosnepomuc...@outlook.com
wrote:

 Think the following update will make the code more portable:

 x += len(line)+len(os.linesep)-1

 Not sure if it's the fastest way to achieve that. :/


Putting len(os.linesep)'s value into a local variable will make accessing
it quite a bit faster. But why would you want to do that?

You mentioned \n translating to two lines, but this won't happen. Windows
will not mess with what you write to your file. It's just that
traditionally windows and windows programs use \r\n instead of just \n. I
think it was for compatibility with os/2 or macintosh (I don't remember
which), which used \r for newlines.

You don't have to follow this convention. If you open a \n-separated file
with *any* text editor other than notepad, your newlines will be okay.
-- 
http://mail.python.org/mailman/listinfo/python-list


Please help with Threading

2013-05-18 Thread Jurgens de Bruin
This is my first script where I want to use the python threading module. I have 
a large dataset which is a list of dict this can be as much as 200 dictionaries 
in the list. The final goal is a  histogram for each dict 16 histograms on a 
page ( 4x4 ) - this already works. 
What I currently do is a create a nested list [ [ {}  ], [ {} ] ] each inner 
list contains 16 dictionaries, thus each inner list is a single page of 16 
histograms. Iterating over the outer-list  and creating the graphs takes to 
long. So I would like multiple inner-list to be processes simultaneously and 
creating the graphs in parallel. 
I am trying to use the python threading for this. I create 4 threads loop over 
the outer-list and send a inner-list to the thread. This seems to work if my 
nested lists only contains 2 elements - thus less elements than threads. 
Currently the scripts runs and then seems to get hung up. I monitor the 
resource  on my mac and python starts off good using 80% and when the 4-thread 
is created the CPU usages drops to 0%. 

My thread creating is based on the following : 
http://www.tutorialspoint.com/python/python_multithreading.htm

Any help would be create!!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please help with Threading

2013-05-18 Thread Peter Otten
Jurgens de Bruin wrote:

 This is my first script where I want to use the python threading module. I
 have a large dataset which is a list of dict this can be as much as 200
 dictionaries in the list. The final goal is a  histogram for each dict 16
 histograms on a page ( 4x4 ) - this already works.
 What I currently do is a create a nested list [ [ {}  ], [ {} ] ] each
 inner list contains 16 dictionaries, thus each inner list is a single page
 of 16 histograms. Iterating over the outer-list  and creating the graphs
 takes to long. So I would like multiple inner-list to be processes
 simultaneously and creating the graphs in parallel.
 I am trying to use the python threading for this. I create 4 threads loop
 over the outer-list and send a inner-list to the thread. This seems to
 work if my nested lists only contains 2 elements - thus less elements than
 threads. Currently the scripts runs and then seems to get hung up. I
 monitor the resource  on my mac and python starts off good using 80% and
 when the 4-thread is created the CPU usages drops to 0%.
 
 My thread creating is based on the following :
 http://www.tutorialspoint.com/python/python_multithreading.htm
 
 Any help would be create!!!

Can you show us the code?

-- 
http://mail.python.org/mailman/listinfo/python-list


python script is not running

2013-05-18 Thread Avnesh Shakya
hi,
i want to run python script which generating data into json fromat, I am 
using crontab, but it's not executing...
my python code--
try.py --

import json
import simplejson as json
import sys

def tryJson():
saved = sys.stdout
correctFile = file('data.json', 'a+')
sys.stdout = correctFile
result = []
i = 1
for i in range(5):
info = {
'a': i+1,
'b': i+2,
'c': i+3,
   }
result.append(info)

if result:
print json.dumps(result, indent=6)
sys.stdout = saved
correctFile.close()
tryJson()

now i m doing ion terminal-
avin@hp:~$ crontab -e
then type -
*/2 * * * * python /home/avin/data/try.py

and save

but it's not executing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to run another file inside current file?

2013-05-18 Thread fjct...@gmail.com
subprocess?



发自我的小米手机

Avnesh Shakya avnesh.n...@gmail.com编写:

hi,
   I want to run a another file inside a ached.add_cron_job(..). how is it 
 possible, please help me, I have a file otherFile.py for execution inside 
 current file.
I know it is very easy question but i m unable to get anything, please help me.
example --

import otherFile
from apscheduler.scheduler import Scheduler
sched = Scheduler()
sched.start()

def job_function():
# Can I here add that file for execution, Or can i add that file directly 
 inside cron?
   
sched.add_cron_job(job_function, month='1-12', day='1-31', 
hour='0-23',minute='44-49')
-- 
http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to write fast into a file in python?

2013-05-18 Thread 88888 Dihedral
Steven D'Aprano於 2013年5月18日星期六UTC+8下午12時01分13秒寫道:
 On Fri, 17 May 2013 21:18:15 +0300, Carlos Nepomuceno wrote:
 
 
 
  I thought there would be a call to format method by '%d\n' % i. It
 
  seems the % operator is a lot faster than format. I just stopped using
 
  it because I read it was going to be deprecated. :( Why replace such a
 
  great and fast operator by a slow method? I mean, why format is been
 
  preferred over %?
 
 
 
 That is one of the most annoying, pernicious myths about Python, probably 
 
 second only to the GIL makes Python slow (it actually makes it fast). 
 
 

The print function in python  is designed to print 
any printable object with a valid string representation.

The format part of the print function has to construct 
a printable string according to the format string 
and the variables passed in on the fly. 

If the acctual string to be printed in the format processing
is obtained in the high level OOP way , then it is definitely 
slow due to the high level overheads and generality requirements.





-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to run another file inside current file?

2013-05-18 Thread Kevin Xi
Hi,
It's better to specify version of python you work with. I know nothing
about python 3 but in python 2 you can do this with `exec`. Example:

 f = file('otherFile.py')
 exec f

For more, read the doc:
http://docs.python.org/2.7/reference/simple_stmts.html#the-exec-statement
HTH


   Kevin

2013/5/18 Avnesh Shakya avnesh.n...@gmail.com

 hi,
I want to run a another file inside a ached.add_cron_job(..). how is it
 possible, please help me, I have a file otherFile.py for execution inside
 current file.
 I know it is very easy question but i m unable to get anything, please
 help me.
 example --

 import otherFile
 from apscheduler.scheduler import Scheduler
 sched = Scheduler()
 sched.start()

 def job_function():
 # Can I here add that file for execution, Or can i add that file
 directly inside cron?

 sched.add_cron_job(job_function, month='1-12', day='1-31',
 hour='0-23',minute='44-49')
 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
让我们忠于理想,让我们面对现实。
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python script is not running

2013-05-18 Thread fjct...@gmail.com
make sure data.json is absolute path
make sure you test it directly without crontab 
in the crontab, execute the script in such way, python scripty  /tmp/log 21 
check the log 



发自我的小米手机

Avnesh Shakya avnesh.n...@gmail.com编写:

hi,
i want to run python script which generating data into json fromat, I am 
 using crontab, but it's not executing...
my python code--
try.py --

import json
import simplejson as json
import sys

def tryJson():
saved = sys.stdout
correctFile = file('data.json', 'a+')
sys.stdout = correctFile
result = []
i = 1
for i in range(5):
info = {
'a': i+1,
'b': i+2,
'c': i+3,
   }
result.append(info)

if result:
print json.dumps(result, indent=6)
sys.stdout = saved
correctFile.close()
tryJson()

now i m doing ion terminal-
avin@hp:~$ crontab -e
then type -
*/2 * * * * python /home/avin/data/try.py

and save

but it's not executing.
-- 
http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please help with Threading

2013-05-18 Thread Jurgens de Bruin
I will post code - the entire scripts is 1000 lines of code - can I post the 
threading functions only?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please help with Threading

2013-05-18 Thread Peter Otten
Jurgens de Bruin wrote:

 I will post code - the entire scripts is 1000 lines of code - can I post
 the threading functions only?

Try to condense it to the relevant parts, but make sure that it can be run 
by us.

As a general note, when you add new stuff to an existing longish script it 
is always a good idea to write it in such a way that you can test it 
standalone so that you can have some confidence that it will work as 
designed once you integrate it with your old code.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Two Dictionaries and a Sum!

2013-05-18 Thread Roy Smith
In article 6012d69f-b65e-4d65-90c4-f04876853...@googlegroups.com,
 Bradley Wright bradley.wright@gmail.com wrote:

 Confusing subject for a confusing problem (to a novice like me of course!)
 Thx for the help in advance folks
 
 I have (2) dictionaries:
 
 prices = {
 banana: 4,
 apple: 2,
 orange: 1.5,
 pear: 3
 }
 
 stock = {
 banana: 6,
 apple: 0,
 orange: 32,
 pear: 15
 }
 
 Here's my instructions:

Hmmm, homework for a class?

 consider this as an inventory and calculate the sum (thats 4*6 = 24 bananas!)

I suspect what you're trying to say is that bananas cost BTC 4 each, and 
since you've got 6 bananas, you've got BTC 24 worth of bananas, yes?  
And now you want to find the total value of your fruit supply?

 HERES MY CODE:
 
 for key in prices:
 print prices[key]*stock[key]
 
 HERES THE OUTPUT:
 
 48.0
 45
 24
 0

So far, so good.  A couple of things you may have noticed along the way:

1) Your orange unit price was a float, so the total value of all your 
oranges is a float as well.  That's how math works in Python.

2) The keys are presented in random order.  To make the output easier to 
interpret, you might want to do:

print key, prices[key]*stock[key]


 ISSUE:
 I need to find a way to add all of those together...any pointers?

The most straight-forward way would be something like:

total = 0
for key in prices:
fruit_subtotal = prices[key]*stock[key]
total += fruit_subtotal
print key, fruit_subtotal

print total


There are better ways to do this in Python, but start like this and get 
that to work.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python script is not running

2013-05-18 Thread Chris Angelico
On Sat, May 18, 2013 at 8:12 PM, Avnesh Shakya avnesh.n...@gmail.com wrote:
 avin@hp:~$ crontab -e
 then type -
 */2 * * * * python /home/avin/data/try.py


You may need to put an explicit path to your Python interpreter. Type:

$ which python

and put that into your crontab.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python script is not running

2013-05-18 Thread Roy Smith
In article mailman.1801.1368883685.3114.python-l...@python.org,
 Chris Angelico ros...@gmail.com wrote:

 On Sat, May 18, 2013 at 8:12 PM, Avnesh Shakya avnesh.n...@gmail.com wrote:
  avin@hp:~$ crontab -e
  then type -
  */2 * * * * python /home/avin/data/try.py
 
 
 You may need to put an explicit path to your Python interpreter. Type:
 
 $ which python
 
 and put that into your crontab.

True.  Somewhat more generally, jobs run under cron have a far more 
barren environment than most people realize.  Or, looking at it a 
different way, most people don't even realize all the ways they depend 
on their environment being set up properly by the login process.

If you've set things like PYTHONPATH, you won't have them set right for 
cron jobs unless you explicitly reset them in your crontab.

It's often instructive to run something like env  /tmp/xxx under 
cron, and compare that to what you get when you run env at a 
command-line prompt.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please help with Threading

2013-05-18 Thread Dave Angel

On 05/18/2013 04:58 AM, Jurgens de Bruin wrote:

This is my first script where I want to use the python threading module. I have 
a large dataset which is a list of dict this can be as much as 200 dictionaries 
in the list. The final goal is a  histogram for each dict 16 histograms on a 
page ( 4x4 ) - this already works.
What I currently do is a create a nested list [ [ {}  ], [ {} ] ] each inner list 
contains 16 dictionaries, thus each inner list is a single page of 16 histograms. 
Iterating over the outer-list  and creating the graphs takes to long. So I would like 
multiple inner-list to be processes simultaneously and creating the graphs in 
parallel.
I am trying to use the python threading for this. I create 4 threads loop over 
the outer-list and send a inner-list to the thread. This seems to work if my 
nested lists only contains 2 elements - thus less elements than threads. 
Currently the scripts runs and then seems to get hung up. I monitor the 
resource  on my mac and python starts off good using 80% and when the 4-thread 
is created the CPU usages drops to 0%.

My thread creating is based on the following : 
http://www.tutorialspoint.com/python/python_multithreading.htm

Any help would be create!!!



CPython, and apparently (all of?) the other current Python 
implementations, uses a GIL to prevent multi-threaded applications from 
shooting themselves in the foot.


However the practical effect of the GIL is that CPU-bound applications 
do not multi-thread efficiently;  the single-threaded version usually 
runs faster.


The place where CPython programs gain from multithreading is where each 
thread spends much of its time waiting for some external trigger.


(More specifically, if such a wait is inside well-written C code, it 
releases the GIL so other threads can get useful work done.  Example is 
a thread waiting for internet activity, and blocks inside a system call)



--
DaveA
--
http://mail.python.org/mailman/listinfo/python-list


Future standard GUI library

2013-05-18 Thread Beinan Li
Not sure if this is the right place to talk about this. Even less sure if I
can
move this discussion to tkinter list, so here I am...

I know this may sound a silly question because no one can see the future.
But ...
Do you think tkinter is going to be the standard python built-in gui
solution as long as python exists?

I couldn't help but wonder if wx or PySide receives better py2 and py3
support, or anything else that prevent
them from getting into the standard python distributions, whether or not
this scene could start to shift ...

I believe this which one of tkinter, wx, qt, is the best gui toolkit for
python flame war has been going on
for ages. I love the fact that python ships a built-in gui solution which
makes shipping a pure-python desktop
application a viable choice. But tkinter does not appear to be the most
time-saving way to write a gui app.
The layout designer support, for one, is next to zero. I tried many
3rd-party designers
and loved PAGE (http://page.sourceforge.net) for a few minutes, then came
the author's comment:

For release 4.0, I spent about two months working with the “Theme” part of
Ttk and have had only partial success. I now believe that the “Theme” part
of Ttk is really a very poor piece of software at all levels - concept,
implementation, and especially documentation. My guess is if it had been
well documented it would have been recognized by even the author as junk. I
find it hard to believe that the people who control Tcl/Tk allowed it in
the code base. I continue to support ttk because of the paned window,
notebook and treeview widgets.

And ttk seems to be a major attraction that keeps people coming back to tk
for the looks. This worries me very much
about whether I should start a gui app using python. Because if ttk is not
a mature technology, I'd avoid premature adoption.
If ttk is out of the question, tkinter will be too. I'd then be forced to
use a 3rd-party solution like wx or qt, which I really don't want to see.

Anyways, this is just some concerns that I hope someone may give his/her
opinions about.

Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Fwd: Re: python script is not running

2013-05-18 Thread Vincent Vande Vyvre




 Message original 
Sujet:  Re: python script is not running
Date :  Sat, 18 May 2013 12:36:55 +0200
De :Vincent Vande Vyvre vincent.vandevy...@swing.be
Pour :  Avnesh Shakya avnesh.n...@gmail.com



Le 18/05/2013 12:12, Avnesh Shakya a écrit :

hi,
 i want to run python script which generating data into json fromat, I am 
using crontab, but it's not executing...
my python code--
try.py --

import json
import simplejson as json
import sys

def tryJson():
 saved = sys.stdout
 correctFile = file('data.json', 'a+')
 sys.stdout = correctFile
 result = []
 i = 1
 for i in range(5):
 info = {
 'a': i+1,
 'b': i+2,
 'c': i+3,
}
 result.append(info)

 if result:
 print json.dumps(result, indent=6)
 sys.stdout = saved
 correctFile.close()
tryJson()

now i m doing ion terminal-
avin@hp:~$ crontab -e
then type -
*/2 * * * * python /home/avin/data/try.py

and save

but it's not executing.

Have a look at /var/mail/yourname, this is a log created by crontab.

--
Vincent V.V.
Oqapy https://launchpad.net/oqapy . Qarte
https://launchpad.net/qarte . PaQager https://launchpad.net/paqager



--
http://mail.python.org/mailman/listinfo/python-list


Re: How to write fast into a file in python?

2013-05-18 Thread Chris Angelico
On Sat, May 18, 2013 at 5:49 PM, Fábio Santos fabiosantos...@gmail.com wrote:
 Putting len(os.linesep)'s value into a local variable will make accessing it
 quite a bit faster. But why would you want to do that?

 You mentioned \n translating to two lines, but this won't happen. Windows
 will not mess with what you write to your file. It's just that traditionally
 windows and windows programs use \r\n instead of just \n. I think it was for
 compatibility with os/2 or macintosh (I don't remember which), which used \r
 for newlines.

 You don't have to follow this convention. If you open a \n-separated file
 with *any* text editor other than notepad, your newlines will be okay.


Into two characters, not two lines, but yes. A file opened in text
mode on Windows will have its lines terminated with two characters.
(And it's old Macs that used to use \r. OS/2 follows the DOS
convention of \r\n, but again, many apps these days are happy with
Unix newlines there too.)

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Future standard GUI library

2013-05-18 Thread Kevin Walzer

Hello,

On 5/18/13 10:03 AM, Beinan Li wrote:


I know this may sound a silly question because no one can see the
future. But ...
Do you think tkinter is going to be the standard python built-in gui
solution as long as python exists?


I don't see any significant clamoring among the Python core developers 
to make a change.




I couldn't help but wonder if wx or PySide receives better py2 and py3
support, or anything else that prevent
them from getting into the standard python distributions, whether or not
this scene could start to shift ...


I am not going to engage in the old UI toolkit flame ware; I will limit 
myself to factual observations and a few opinions about Tkinter without 
placing it against other toolkits.


Python has the PEP process for suggesting changes to the core language 
and libraries. Changing the default UI toolkit would require someone to 
submit a proposal, get it approved, provide the implementation, and 
commit to maintaining the implementation over the long term. You propose 
it, you own it.


Thus far no one has done this. I would think the only person who would 
be in a position to propose wxPython would be Robin Dunn since he is the 
primary copyright holder, and to my knowledge he has never done so. As 
for Pyside, it was not part of the transition of Qt from Nokia to Digia, 
and so it appears to be orphaned. PyQt might be an alternative, but I 
don't think Phil Thompson would ever submit it, as it would likely 
affect his livelihood.


Given these facts, it's safe to say that Tkinter will remain the default 
GUI toolkit in the stdlib for some years to come.




I believe this which one of tkinter, wx, qt, is the best gui toolkit
for python flame war has been going on
for ages. I love the fact that python ships a built-in gui solution
which makes shipping a pure-python desktop
application a viable choice. But tkinter does not appear to be the most
time-saving way to write a gui app.
The layout designer support, for one, is next to zero. I tried many
3rd-party designers
and loved PAGE (http://page.sourceforge.net) for a few minutes, then
came the author's comment:


PAGE strikes me as an odd choice for a Python developer to develop a Tk 
UI. It's a descendent of the old Visual Tcl tool, and is run from Tcl 
and not Python. VTcl was always famous for producing a huge pot of 
spaghetti UI code that couldn't be easily modified outside the tool. I 
have also tried many Tk UI tools including VTcl, SpecTcl, and the 
orphaned tool from ActiveState, and have concluded that writing my own 
code is both simpler and faster. As always, your mileage may vary.




For release 4.0, I spent about two months working with the “Theme” part
of Ttk and have had only partial success. I now believe that the “Theme”
part of Ttk is really a very poor piece of software at all levels -
concept, implementation, and especially documentation. My guess is if it
had been well documented it would have been recognized by even the
author as junk. I find it hard to believe that the people who control
Tcl/Tk allowed it in the code base. I continue to support ttk because of
the paned window, notebook and treeview widgets.


The implementation of the ttk widgets is quite complex--that, in turn, 
makes their documentation complex, and the complexity is a drawback. 
It's hard to customize the ttk themes, especially compared to 
customizing standard Tk widgets. I'm one of the core Tk developers, and 
I don't fully understand the themed widgets' internals or how to 
customize them. But it's not fair to say that they are junk. The 
author of PAGE may think so, but many would disagree. I think the 
widgets work quite well, especially if used in their default mode. It's 
difficult to overstate the improvement in the look and feel of my Tk 
apps on the Mac when I switched to using the themed widgets.




And ttk seems to be a major attraction that keeps people coming back to
tk for the looks. This worries me very much
about whether I should start a gui app using python. Because if ttk is
not a mature technology, I'd avoid premature adoption.
If ttk is out of the question, tkinter will be too. I'd then be forced
to use a 3rd-party solution like wx or qt, which I really don't want to see.


ttk is a mature technology. The initial specification, code, and docs 
were developed by Joe English nearly a decade ago (see 
http://tktable.sourceforge.net/tile/tile-tcl2004.pdf), and they had been 
accepted into Tcl/Tk's core in version 8.5 (released in 2007). The 
earliest work on integrating these widgets into Python began in 2008, 
and they were formally released in 2010.  I would say that ttk is 
mature, stable, and unlikely to undergo radical change in the future.


Guilherme Polo has done superb work in integrating the themed widgets 
into Python--it's the most significant UI advance in Python's stdlib in 
years. You are quite safe in developing against this API, unless your 
taste simply does not run to using the ttk 

Re: python script is not running

2013-05-18 Thread Terry Jan Reedy

On 5/18/2013 6:12 AM, Avnesh Shakya wrote:

hi,
 i want to run python script which generating data into json fromat, I am 
using crontab, but it's not executing...
my python code--
try.py --

import json
import simplejson as json
import sys

def tryJson():
 saved = sys.stdout
 correctFile = file('data.json', 'a+')
 sys.stdout = correctFile


Don't need to change stdout.


 result = []
 i = 1
 for i in range(5):
 info = {
 'a': i+1,
 'b': i+2,
 'c': i+3,
}
 result.append(info)


What is you want to add print result for debugging?


 if result:
 print json.dumps(result, indent=6)


Either use print  correctFile, correctFile.write (do you really want 
the extra '\n' that print adds?), or, do the future import of print as 
function and pass correctFile as the file argument



 sys.stdout = saved
 correctFile.close()
tryJson()



--
http://mail.python.org/mailman/listinfo/python-list


Re: how to run another file inside current file?

2013-05-18 Thread Terry Jan Reedy

On 5/18/2013 7:15 AM, Kevin Xi wrote:

Hi,
It's better to specify version of python you work with.


Absolutely.


 I know nothing

about python 3 but in python 2 you can do this with `exec`. Example:

  f = file('otherFile.py')
  exec f


Py 2 has execfile that does the above. Py 3 do as above except that exec 
is a function.


with open('otherfile.py') as f:
  exex(f)



For more, read the doc:
http://docs.python.org/2.7/reference/simple_stmts.html#the-exec-statement
HTH





--
http://mail.python.org/mailman/listinfo/python-list


RE: How to write fast into a file in python?

2013-05-18 Thread Carlos Nepomuceno
Python really writes '\n\r' on Windows. Just check the files.

Internal representations only keep '\n' for simplicity, but if you wanna keep 
track of the file length you have to take that into account. ;)


 Date: Sat, 18 May 2013 08:49:55 +0100 
 Subject: RE: How to write fast into a file in python? 
 From: fabiosantos...@gmail.com 
 To: carlosnepomuc...@outlook.com 
 CC: python-list@python.org 
  
  
 On 17 May 2013 19:38, Carlos Nepomuceno  
 carlosnepomuc...@outlook.commailto:carlosnepomuc...@outlook.com  
 wrote: 
  
  Think the following update will make the code more portable: 
  
  x += len(line)+len(os.linesep)-1 
  
  Not sure if it's the fastest way to achieve that. :/ 
  
  
 Putting len(os.linesep)'s value into a local variable will make  
 accessing it quite a bit faster. But why would you want to do that? 
  
 You mentioned \n translating to two lines, but this won't happen.  
 Windows will not mess with what you write to your file. It's just that  
 traditionally windows and windows programs use \r\n instead of just \n.  
 I think it was for compatibility with os/2 or macintosh (I don't  
 remember which), which used \r for newlines. 
  
 You don't have to follow this convention. If you open a \n-separated  
 file with *any* text editor other than notepad, your newlines will be  
 okay.   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python script is not running

2013-05-18 Thread woooee
The obvious question, do you have the shebang on the first line so the
OS knows it's to be run as a Python program?  Also I would change
tryJson() to
if __name__ == __main__':
tryJson()
This probably won't make any difference but you will have the bases
covered.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python script is not running

2013-05-18 Thread Chris Angelico
On Sun, May 19, 2013 at 3:35 AM, woooee woo...@gmail.com wrote:
 The obvious question, do you have the shebang on the first line so the
 OS knows it's to be run as a Python program?

That won't make any difference; the cron job specifically stipulates
the interpreter. It just needs to be done with a full path.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


SQLObject 1.4.0

2013-05-18 Thread Oleg Broytman
Hello!

I'm pleased to announce version 1.4.0, the first stable release of branch
1.4 of SQLObject.


What's new in SQLObject
===

Features  Interface


* Support for PostgreSQL 8.1 is dropped. The minimal supported version of
  PostgreSQL is 8.2 now.

* Optimization in PostgresConnection: use INSERT...RETURNING id
  to get the autoincremented id in one query instead of two
  (INSERT + SELECT id).

* Changed the way to get if the table has identity in MS SQL.

* NCHAR/NVARCHAR and N''-quoted strings for MS SQL.

Contributors for this release are Ken Lalonde and Andrew Ziem.


For a more complete list, please see the news:
http://sqlobject.org/News.html


What is SQLObject
=

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).


Where is SQLObject
==

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

Download:
https://pypi.python.org/pypi/SQLObject/1.4.0

News and changes:
http://sqlobject.org/News.html

Oleg.
-- 
 Oleg Broytmanhttp://phdru.name/p...@phdru.name
   Programmers don't die, they just GOSUB without RETURN.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python script is not running

2013-05-18 Thread Vincent Vande Vyvre

Le 18/05/2013 19:59, Chris Angelico a écrit :

On Sun, May 19, 2013 at 3:35 AM, woooee woo...@gmail.com wrote:

The obvious question, do you have the shebang on the first line so the
OS knows it's to be run as a Python program?

That won't make any difference; the cron job specifically stipulates
the interpreter. It just needs to be done with a full path.

ChrisA

Not necessary, I use crontab without problem with this line:

25 16 18 5 * export DISPLAY=:0  LC_CTYPE=fr_FR.utf-8 
Lang=fr_FR.utf-8 python /usr/bin/qarte -a 1


... on Ubuntu.

--
Vincent V.V.
Oqapy https://launchpad.net/oqapy . Qarte 
https://launchpad.net/qarte . PaQager https://launchpad.net/paqager

--
http://mail.python.org/mailman/listinfo/python-list


TypeError: unbound method add() must be called with BinaryTree instance as first argument (got nothing instead)

2013-05-18 Thread Dan Stromberg
I'm getting the error in the subject, from the following code:
def add(self, key):

Adds a node containing I{key} to the subtree
rooted at I{self}, returning the added node.

node = self.find(key)
if not node:
node.key = key
# placeholder
node.left, node.right = self.__class__(parent=node),
self.__class__(parent=node)
return (False, node)
else:
if random.random()  0.5:
print('node.left is %s' % node.left)
return BinaryTree.add(self=node.left, key=key)
else:
print('node.right is %s' % node.left)
return BinaryTree.add(self=node.right, key=key)

The above add() method is part of a BinaryTree(object) class, whose
subclass is RedBlackTree.

We need to explicitly call BinaryTree.add() with an explict self, to avoid
inappropriately calling RedBlackTree.add().; BinaryTree.add() is being
called with a RedBlackTree instance as self.

The debugging print and traceback look like:
node.left is  0 -1 red
Traceback (most recent call last):
  File app_main.py, line 51, in run_toplevel
  File test-red_black_tree_mod, line 328, in module
test()
  File test-red_black_tree_mod, line 316, in test
all_good = test_duplicates()
  File test-red_black_tree_mod, line 194, in test_duplicates
tree.add(value)
  File
/home/dstromberg/src/home-svn/red-black-tree-mod/trunk/duncan/red_black_bag_mod.py,
line 919, in add
(replaced, node) = super(RedBlackTree, self).add(key=key)
  File
/home/dstromberg/src/home-svn/red-black-tree-mod/trunk/duncan/red_black_bag_mod.py,
line 376, in add
return BinaryTree.add(self=node.left, key=key)
TypeError: unbound method add() must be called with BinaryTree instance as
first argument (got nothing instead)

Why is it complaining that .add() is getting nothing, when node.left isn't
None?  As you can see above the traceback, it's got a value represented by
node.left is  0 -1 red.

python 2.x, python 3.x and pypy all give this same error, though jython
errors out at a different point in the same method.

Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: TypeError: unbound method add() must be called with BinaryTree instance as first argument (got nothing instead)

2013-05-18 Thread Peter Otten
Dan Stromberg wrote:

 I'm getting the error in the subject, from the following code:
 def add(self, key):
 
 Adds a node containing I{key} to the subtree
 rooted at I{self}, returning the added node.
 
 node = self.find(key)
 if not node:
 node.key = key
 # placeholder
 node.left, node.right = self.__class__(parent=node),
 self.__class__(parent=node)
 return (False, node)
 else:
 if random.random()  0.5:
 print('node.left is %s' % node.left)
 return BinaryTree.add(self=node.left, key=key)
 else:
 print('node.right is %s' % node.left)
 return BinaryTree.add(self=node.right, key=key)
 
 The above add() method is part of a BinaryTree(object) class, whose
 subclass is RedBlackTree.
 
 We need to explicitly call BinaryTree.add() with an explict self, to avoid
 inappropriately calling RedBlackTree.add().; BinaryTree.add() is being
 called with a RedBlackTree instance as self.
 
 The debugging print and traceback look like:
 node.left is  0 -1 red
 Traceback (most recent call last):
   File app_main.py, line 51, in run_toplevel
   File test-red_black_tree_mod, line 328, in module
 test()
   File test-red_black_tree_mod, line 316, in test
 all_good = test_duplicates()
   File test-red_black_tree_mod, line 194, in test_duplicates
 tree.add(value)
   File
 /home/dstromberg/src/home-svn/red-black-tree-
mod/trunk/duncan/red_black_bag_mod.py,
 line 919, in add
 (replaced, node) = super(RedBlackTree, self).add(key=key)
   File
 /home/dstromberg/src/home-svn/red-black-tree-
mod/trunk/duncan/red_black_bag_mod.py,
 line 376, in add
 return BinaryTree.add(self=node.left, key=key)
 TypeError: unbound method add() must be called with BinaryTree instance as
 first argument (got nothing instead)
 
 Why is it complaining that .add() is getting nothing, when node.left isn't
 None?  As you can see above the traceback, it's got a value represented by
 node.left is  0 -1 red.
 
 python 2.x, python 3.x and pypy all give this same error, though jython
 errors out at a different point in the same method.
 
 Thanks!

I never ran into that, but apparently you cannot pass self as a keyword 
parameter:

 class A(object):
... def add(self): pass
... 
 a = A()
 A.add(a)
 A.add(self=a)
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: unbound method add() must be called with A instance as first 
argument (got nothing instead)


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to write fast into a file in python?

2013-05-18 Thread Dan Stromberg
With CPython 2.7.3:
./t
time taken to write a file of size 52428800  is  15.86 seconds

time taken to write a file of size 52428800  is  7.91 seconds

time taken to write a file of size 52428800  is  9.64 seconds


With pypy-1.9:
./t
time taken to write a file of size 52428800  is  3.708232 seconds

time taken to write a file of size 52428800  is  4.868304 seconds

time taken to write a file of size 52428800  is  1.93612 seconds


Here's the code:
#!/usr/local/pypy-1.9/bin/pypy
#!/usr/bin/python

import sys
import time
import StringIO

sys.path.insert(0, '/usr/local/lib')
import bufsock

def create_file_numbers_old(filename, size):
start = time.clock()

value = 0
with open(filename, w) as f:
while f.tell()  size:
f.write({0}\n.format(value))
value += 1

end = time.clock()

print time taken to write a file of size, size,  is , (end -start),
seconds \n

def create_file_numbers_bufsock(filename, intended_size):
start = time.clock()

value = 0
with open(filename, w) as f:
bs = bufsock.bufsock(f)
actual_size = 0
while actual_size  intended_size:
string = {0}\n.format(value)
actual_size += len(string) + 1
bs.write(string)
value += 1
bs.flush()

end = time.clock()

print time taken to write a file of size, intended_size,  is , (end
-start), seconds \n


def create_file_numbers_file_like(filename, intended_size):
start = time.clock()

value = 0
with open(filename, w) as f:
file_like = StringIO.StringIO()
actual_size = 0
while actual_size  intended_size:
string = {0}\n.format(value)
actual_size += len(string) + 1
file_like.write(string)
value += 1
file_like.seek(0)
f.write(file_like.read())

end = time.clock()

print time taken to write a file of size, intended_size,  is , (end
-start), seconds \n

create_file_numbers_old('output.txt', 50 * 2**20)
create_file_numbers_bufsock('output2.txt', 50 * 2**20)
create_file_numbers_file_like('output3.txt', 50 * 2**20)




On Thu, May 16, 2013 at 9:35 PM, lokeshkopp...@gmail.com wrote:

 On Friday, May 17, 2013 8:50:26 AM UTC+5:30, lokesh...@gmail.com wrote:
  I need to write numbers into a file upto 50mb and it should be fast
 
  can any one help me how to do that?
 
  i had written the following code..
 
 
 ---
 
  def create_file_numbers_old(filename, size):
 
  start = time.clock()
 
 
 
  value = 0
 
  with open(filename, w) as f:
 
  while f.tell() size:
 
  f.write({0}\n.format(value))
 
  value += 1
 
 
 
  end = time.clock()
 
 
 
  print time taken to write a file of size, size,  is , (end -start),
 seconds \n
 
 
 --
 
  it takes about 20sec i need 5 to 10 times less than that.
 size = 50mb
 --
 http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to write fast into a file in python?

2013-05-18 Thread Roy Smith
In article mailman.1813.1368904489.3114.python-l...@python.org,
 Dennis Lee Bieber wlfr...@ix.netcom.com wrote:

 tOn Sat, 18 May 2013 08:49:55 +0100, Fábio Santos
 fabiosantos...@gmail.com declaimed the following in
 gmane.comp.python.general:
 
 
  You mentioned \n translating to two lines, but this won't happen. Windows
  will not mess with what you write to your file. It's just that
  traditionally windows and windows programs use \r\n instead of just \n. I
  think it was for compatibility with os/2 or macintosh (I don't remember
  which), which used \r for newlines.
 
   Neither... It goes back to Teletype machines where one sent a
 carriage return to move the printhead back to the left, then sent a line
 feed to advance the paper (while the head was still moving left), and in
 some cases also provided a rub-out character (a do-nothing) to add an
 additional character time delay.

The delay was important.  It took more than one character time for the 
print head to get back to the left margin.  If you kept sending 
printable characters while the print head was still flying back, they 
would get printed in the middle of the line (perhaps blurred a little).

There was also a dashpot which cushioned the head assembly when it 
reached the left margin.  Depending on how well adjusted things were 
this might take another character time or two to fully settle down.

You can still see the remnants of this in modern Unix systems:

$ stty -a
speed 9600 baud; rows 40; columns 136; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 
= M-^?; swtch = undef; start = ^Q; stop = ^S; susp = ^Z;
rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon 
-ixoff -iuclc ixany imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 
vt0 ff0
isig icanon iexten echo echoe -echok -echonl -noflsh -xcase -tostop 
-echoprt echoctl echoke

The nl0 and cr0 mean it's configured to insert 0 delay after 
newlines and carriage returns.  Whether setting a non-zero delay 
actually does anything useful anymore is an open question, but the 
drivers still accept the settings.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: TypeError: unbound method add() must be called with BinaryTree instance as first argument (got nothing instead)

2013-05-18 Thread Peter Otten
Dan Stromberg wrote:

 python 2.x, python 3.x and pypy all give this same error, though jython
 errors out at a different point in the same method.

By the way, 3.x doesn't have unbound methods, so that should work.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Future standard GUI library

2013-05-18 Thread Terry Jan Reedy

On 5/18/2013 10:03 AM, Beinan Li wrote:

Not sure if this is the right place to talk about this.


It is.


Even less sure if I can
move this discussion to tkinter list,


The idea of replacing tkinter is not about improving tkinter ;-).


Do you think tkinter is going to be the standard python built-in gui
solution as long as python exists?


AT the moment, there is nothing really comparable that is a realistic 
candidate to replace tkinter. Tkinter is a tcl-based c gui library. wx 
and qt4 are gui application frameworks that include a gui library -- and 
much more that duplicate part of Python's stdlib. They, and consequently 
their Python wrappers, are too big. That is quite aside from the fact 
that the authors of the wrappers have good reason to not donate their 
code, but stay independent.


PyGui was designed as a gui library comparable to tkinter and a possible 
replacement. But according to the web page, it is still not completely 
ready for py 3 (the last update was July 2011).

http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/

I think a tkinter replacement should be written for at least 3.4+, so it 
can use the new 3.3 unicode implementation and use or at least integrate 
with the new 3.4 event loop that will be part of the planned new async 
library.


One test for any new gui library is whether idle can be rewritten in it. 
It heavily uses the tag features of the tk text widget.


TJR



--
http://mail.python.org/mailman/listinfo/python-list


Re: TypeError: unbound method add() must be called with BinaryTree instance as first argument (got nothing instead)

2013-05-18 Thread Terry Jan Reedy

On 5/18/2013 3:46 PM, Peter Otten wrote:

Dan Stromberg wrote:


python 2.x, python 3.x and pypy all give this same error, though jython
errors out at a different point in the same method.


By the way, 3.x doesn't have unbound methods, so that should work.


It does for this example (3.3.1)
 c = C()
 c.m()
__main__.C object at 0x033FC5F8
 C.m(c)
__main__.C object at 0x033FC5F8
 C.m(self=c)
__main__.C object at 0x033FC5F8



--
http://mail.python.org/mailman/listinfo/python-list


Re: How to write fast into a file in python?

2013-05-18 Thread Fábio Santos
On 18 May 2013 20:19, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:

 tOn Sat, 18 May 2013 08:49:55 +0100, Fábio Santos
 fabiosantos...@gmail.com declaimed the following in
 gmane.comp.python.general:


  You mentioned \n translating to two lines, but this won't happen. Windows
  will not mess with what you write to your file. It's just that
  traditionally windows and windows programs use \r\n instead of just \n. I
  think it was for compatibility with os/2 or macintosh (I don't remember
  which), which used \r for newlines.
 
 Neither... It goes back to Teletype machines where one sent a
 carriage return to move the printhead back to the left, then sent a line
 feed to advance the paper (while the head was still moving left), and in
 some cases also provided a rub-out character (a do-nothing) to add an
 additional character time delay.

 TRS-80 Mod 1-4 used cr for new line, I believe Apple used lf
 for new line... And both lost the ability to move down the page
 without also resetting the carriage to the left. In a world where both
 crlf is used, one could draw a vertical line of | by just spacing
 across the first line, printing |, then repeat lfbkspc| until done.
 To do the same with conventional lf is new line/return one has to
 transmit all those spaces for each line...

 At 300baud, that took time



On Sat, May 18, 2013 at 6:00 PM, Carlos Nepomuceno
carlosnepomuc...@outlook.com wrote:
 Python really writes '\n\r' on Windows. Just check the files.

 Internal representations only keep '\n' for simplicity, but if you wanna keep 
 track of the file length you have to take that into account. ;)


On Sat, May 18, 2013 at 3:29 PM, Chris Angelico ros...@gmail.com wrote:
 Into two characters, not two lines, but yes. A file opened in text
 mode on Windows will have its lines terminated with two characters.
 (And it's old Macs that used to use \r. OS/2 follows the DOS
 convention of \r\n, but again, many apps these days are happy with
 Unix newlines there too.)

 ChrisA

Thanks for your corrections and explanations. I stand corrected and
have learned something.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Future standard GUI library

2013-05-18 Thread Steven D'Aprano
On Sat, 18 May 2013 10:03:02 -0400, Beinan Li wrote:

 Do you think tkinter is going to be the standard python built-in gui
 solution as long as python exists?

Probably.

 I couldn't help but wonder if wx or PySide receives better py2 and py3
 support, or anything else that prevent them from getting into the
 standard python distributions, whether or not this scene could start to
 shift ...

One of the major issues preventing projects being added to the standard 
library is the maintenance schedule. Python's schedule for new releases 
is quite conservative and slow. If, say, wxPython was added to the std 
lib, it would have to follow Python's schedule:

* most backwards incompatible changes would be forbidden;

* those that are allowed would require a minimum of two major releases 
(three years) before removing functionality;

* about four bug-fix releases (I think?) per year.

If a project is used to (say) weekly releases, dropping down to Python's 
schedule can be rather painful.

Once something has been added to the standard library, it more or less 
has to have a stable API, become conservative about changes, and care 
more about backwards-compatibility than new features. Stability and 
consistency become paramount. Many excellent, popular packages cannot 
live under those restrictions, and so will never be part of the standard 
library.

Tkinter is good in this regard, because it is a wrapper around Tk/Tcl, 
which is equally stable and conservative as Python. Possibly even more so.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Future standard GUI library

2013-05-18 Thread Beinan Li
Thanks for the clarification, Kevin.
It's nice to have a tk dev standing out :-)
This more or less convinced me about the trend.

I also agree that it would be probably a simpler and more maintainable way
to write my own tk(inter) code than using any existing 3rd-party designers.


Beinan

On Sat, May 18, 2013 at 1:40 PM, python-list-requ...@python.org wrote:



 -- Forwarded message --
 From: Kevin Walzer k...@codebykevin.com
 To: python-list@python.org
 Cc:
 Date: Sat, 18 May 2013 11:32:04 -0400
 Subject: Re: Future standard GUI library
 Hello,

 On 5/18/13 10:03 AM, Beinan Li wrote:

  I know this may sound a silly question because no one can see the
 future. But ...
 Do you think tkinter is going to be the standard python built-in gui
 solution as long as python exists?


 I don't see any significant clamoring among the Python core developers to
 make a change.


 I couldn't help but wonder if wx or PySide receives better py2 and py3
 support, or anything else that prevent
 them from getting into the standard python distributions, whether or not
 this scene could start to shift ...


 I am not going to engage in the old UI toolkit flame ware; I will limit
 myself to factual observations and a few opinions about Tkinter without
 placing it against other toolkits.

 Python has the PEP process for suggesting changes to the core language and
 libraries. Changing the default UI toolkit would require someone to submit
 a proposal, get it approved, provide the implementation, and commit to
 maintaining the implementation over the long term. You propose it, you own
 it.

 Thus far no one has done this. I would think the only person who would be
 in a position to propose wxPython would be Robin Dunn since he is the
 primary copyright holder, and to my knowledge he has never done so. As for
 Pyside, it was not part of the transition of Qt from Nokia to Digia, and so
 it appears to be orphaned. PyQt might be an alternative, but I don't think
 Phil Thompson would ever submit it, as it would likely affect his
 livelihood.

 Given these facts, it's safe to say that Tkinter will remain the default
 GUI toolkit in the stdlib for some years to come.


 I believe this which one of tkinter, wx, qt, is the best gui toolkit
 for python flame war has been going on
 for ages. I love the fact that python ships a built-in gui solution
 which makes shipping a pure-python desktop
 application a viable choice. But tkinter does not appear to be the most
 time-saving way to write a gui app.
 The layout designer support, for one, is next to zero. I tried many
 3rd-party designers
 and loved PAGE (http://page.sourceforge.net) for a few minutes, then
 came the author's comment:


 PAGE strikes me as an odd choice for a Python developer to develop a Tk
 UI. It's a descendent of the old Visual Tcl tool, and is run from Tcl and
 not Python. VTcl was always famous for producing a huge pot of spaghetti UI
 code that couldn't be easily modified outside the tool. I have also tried
 many Tk UI tools including VTcl, SpecTcl, and the orphaned tool from
 ActiveState, and have concluded that writing my own code is both simpler
 and faster. As always, your mileage may vary.


 For release 4.0, I spent about two months working with the “Theme” part
 of Ttk and have had only partial success. I now believe that the “Theme”
 part of Ttk is really a very poor piece of software at all levels -
 concept, implementation, and especially documentation. My guess is if it
 had been well documented it would have been recognized by even the
 author as junk. I find it hard to believe that the people who control
 Tcl/Tk allowed it in the code base. I continue to support ttk because of
 the paned window, notebook and treeview widgets.


 The implementation of the ttk widgets is quite complex--that, in turn,
 makes their documentation complex, and the complexity is a drawback. It's
 hard to customize the ttk themes, especially compared to customizing
 standard Tk widgets. I'm one of the core Tk developers, and I don't fully
 understand the themed widgets' internals or how to customize them. But it's
 not fair to say that they are junk. The author of PAGE may think so, but
 many would disagree. I think the widgets work quite well, especially if
 used in their default mode. It's difficult to overstate the improvement in
 the look and feel of my Tk apps on the Mac when I switched to using the
 themed widgets.


 And ttk seems to be a major attraction that keeps people coming back to
 tk for the looks. This worries me very much
 about whether I should start a gui app using python. Because if ttk is
 not a mature technology, I'd avoid premature adoption.
 If ttk is out of the question, tkinter will be too. I'd then be forced
 to use a 3rd-party solution like wx or qt, which I really don't want to
 see.


 ttk is a mature technology. The initial specification, code, and docs were
 developed by Joe English nearly a decade ago (see
 

Re: How to write fast into a file in python?

2013-05-18 Thread Steven D'Aprano
On Sat, 18 May 2013 15:14:31 -0400, Dennis Lee Bieber wrote:

 tOn Sat, 18 May 2013 08:49:55 +0100, Fábio Santos
 fabiosantos...@gmail.com declaimed the following in
 gmane.comp.python.general:
 
 
 You mentioned \n translating to two lines, but this won't happen.
 Windows will not mess with what you write to your file. 

Windows certainly may mess with what you write to your file, if it is 
opened in Text mode instead of Binary mode. In text mode, Windows will:

- interpret Ctrl-Z characters as End Of File when reading;

- convert \r\n to \n when reading;

- convert \n to \r\n when writing.

http://msdn.microsoft.com/en-us/library/z5hh6ee9(v=vs.80).aspx


 It's just that
 traditionally windows and windows programs use \r\n instead of just \n.
 I think it was for compatibility with os/2 or macintosh (I don't
 remember which), which used \r for newlines.

   Neither... It goes back to Teletype machines where one sent a
 carriage return to move the printhead back to the left, then sent a line
 feed to advance the paper (while the head was still moving left), and in
 some cases also provided a rub-out character (a do-nothing) to add an
 additional character time delay.

Yes, if you go back far enough, you get to teletype machines. But Windows 
inherits its text-mode behaviour from DOS, which inherits it from CP/M. 


   TRS-80 Mod 1-4 used cr for new line, I believe Apple used lf
 for new line... 

I can't comment about TRS, but classic Apple Macs (up to System 9) used 
carriage return \r as the line separator.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python script is not running

2013-05-18 Thread Chris Angelico
On Sun, May 19, 2013 at 4:43 AM, Vincent Vande Vyvre
vincent.vandevy...@swing.be wrote:
 Le 18/05/2013 19:59, Chris Angelico a écrit :

 On Sun, May 19, 2013 at 3:35 AM, woooee woo...@gmail.com wrote:

 The obvious question, do you have the shebang on the first line so the
 OS knows it's to be run as a Python program?

 That won't make any difference; the cron job specifically stipulates
 the interpreter. It just needs to be done with a full path.

 ChrisA

 Not necessary, I use crontab without problem with this line:

 25 16 18 5 * export DISPLAY=:0  LC_CTYPE=fr_FR.utf-8 Lang=fr_FR.utf-8
 python /usr/bin/qarte -a 1

 ... on Ubuntu.

Everything's configurable. I'd like to hear back from the OP though;
as Roy said, checking 'env' from a cron job will reveal much.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for philosophers

2013-05-18 Thread 88888 Dihedral
Chris Angelico於 2013年5月14日星期二UTC+8上午12時24分44秒寫道:
 On Tue, May 14, 2013 at 12:53 AM, rusi rustompm...@gmail.com wrote:
 
  int fact(int n, int acc)
 
  {
 
return !n? acc : fact(n-1,acc*n);
 
  }
 
  -
 
  When I run these, the C happily keeps giving answers until a million
 
 
 
  However examined closely we find that though the C is giving answers
 
  its giving junk after around 12
 
  fact 17 is -288522240
 
  And 35 onwards its 0 (!!)
 
 
 
 That'll depend on your integer size. If it's a 32-bit integer, you
 
 can't store numbers greater than 2**31-1 (if you declared it as
 
 'unsigned int', you could go all the way to 2**32-1). I'm sure you
 
 could write this to use the GNU Multi-Precision library, but it'd be a
 
 lot more complicated. However, as far as I know, the Turing machine
 
 never promises that; its cells aren't meant to be infinite integers.
 
 
 
 The Python script is, of course, governed by sys.setrecursionlimit().
 
 But by adding a simple driver, we can test the real limit:
 
 
 
 import sys
 
 
 
 def fact(n,acc=1):
 
 return acc if not n else fact(n-1,n*acc)
 
 
 
 n=2
 
 while True:
 
 sys.setrecursionlimit(n+2)
 
 print(fact,n,has,len(str(fact(n))),digits)
 
 n*=2
 
 
 
 On my 64-bit system, running a recent trunk build of CPython 3.4, it
 
 can calculate 8192! but not 16384! (segfault). The limit seems to be
 
 12772; after that, boom. Your crash-point will quite probably vary,
 
 and I'd say there'll be compile-time options that would change that.
 
 
 
 Of course, after playing with this in Python, I had to try out Pike.
 
 Using the exact same code you proposed for C, but with a different
 
 main() to save me the hassle of keying in numbers manually, I get
 
 this:
 
 
 
 fact 8192 has 28504 digits - 0.026 secs
 
 fact 16384 has 61937 digits - 0.097 secs
 
 fact 32768 has 133734 digits - 0.389 secs
 
 fact 65536 has 287194 digits - 1.628 secs
 
 fact 131072 has 613842 digits - 7.114 secs
 
 fact 262144 has 1306594 digits - 31.291 secs
 
 fact 524288 has 2771010 digits - 133.146 secs
 
 
 
 It's still going. One core consumed, happily working on 1048576!, and
 
 not actually using all that much memory. Hmm looks like the Pike
 
 optimizer has turned this non-recursive. Okay, let's tweak it so it's
 
 not tail-recursion-optimizable:
 
 
 
   return n?n*fact(n-1,1):1;
 
 
 
 Now it bombs at 65536, saying:
 
 
 
 Svalue stack overflow. (99624 of 10 entries on stack, needed 256
 
 more entries)
 
 
 
 Hey, it's better than a segfault, which is what C would have done :)
 
 And it's a tweakable value, though I don't know what the consequences
 
 are of increasing it (presumably increased RAM usage for all Pike
 
 programs).
 
 
 
 Your final conclusion is of course correct; nothing we build can be
 
 truly infinite. But we can certainly give some very good
 
 approximations, if we're prepared to pay for them. The reality is,
 
 though, that we usually do not want to pay for approximations to
 
 infinity; why is IEEE 754 floating point so much more used than, say,
 
 arbitrary-precision rational? Most of the time, we'd rather have good
 
 performance and adequate accuracy than abysmal performance and perfect
 
 accuracy. But hey, if you want to render a Mandelbrot set and zoom in
 
 to infinity, the option IS there.
 
 
 
 ChrisA

Hey, ChisA, are you delibrately to write a recursive version
to demonstrate the stack depth problem in Python?

def fact(n):
   ret=1
   if n1: # integer checking is not used but can be added
  for x in xrange(n): ret*=x
   #print ret # debugging only for long integers 
   return ret 



In a 32 or 64 bit system, this non-recursive verssion
will be limited by the heap space not by the stack limit.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Please help with Threading

2013-05-18 Thread Carlos Nepomuceno

 To: python-list@python.org
 From: wlfr...@ix.netcom.com
 Subject: Re: Please help with Threading
 Date: Sat, 18 May 2013 15:28:56 -0400

 On Sat, 18 May 2013 01:58:13 -0700 (PDT), Jurgens de Bruin
 debrui...@gmail.com declaimed the following in
 gmane.comp.python.general:

 This is my first script where I want to use the python threading module. I 
 have a large dataset which is a list of dict this can be as much as 200 
 dictionaries in the list. The final goal is a histogram for each dict 16 
 histograms on a page ( 4x4 ) - this already works.
 What I currently do is a create a nested list [ [ {} ], [ {} ] ] each inner 
 list contains 16 dictionaries, thus each inner list is a single page of 16 
 histograms. Iterating over the outer-list and creating the graphs takes to 
 long. So I would like multiple inner-list to be processes simultaneously and 
 creating the graphs in parallel.
 I am trying to use the python threading for this. I create 4 threads loop 
 over the outer-list and send a inner-list to the thread. This seems to work 
 if my nested lists only contains 2 elements - thus less elements than 
 threads. Currently the scripts runs and then seems to get hung up. I monitor 
 the resource on my mac and python starts off good using 80% and when the 
 4-thread is created the CPU usages drops to 0%.


 The odds are good that this is just going to run slower...

Just been told that GIL doesn't make things slower, but as I didn't know that 
such a thing even existed I went out looking for more info and found that 
document: http://www.dabeaz.com/python/UnderstandingGIL.pdf

Is it current? I didn't know Python threads aren't preemptive. Seems to be 
something really old considering the state of the art on parallel execution on 
multi-cores.

What's the catch on making Python threads preemptive? Are there any ongoing 
projects to make that?

 One: The common Python implementation uses a global interpreter lock
 to prevent interpreted code from interfering with itself in multiple
 threads. So number cruncher applications don't gain any speed from
 being partitioned into thread -- even on a multicore processor, only one
 thread can have the GIL at a time. On top of that, you have the overhead
 of the interpreter switching between threads (GIL release on one thread,
 GIL acquire for the next thread).

 Python threads work fine if the threads either rely on intelligent
 DLLs for number crunching (instead of doing nested Python loops to
 process a numeric array you pass it to something like NumPy which
 releases the GIL while crunching a copy of the array) or they do lots of
 I/O and have to wait for I/O devices (while one thread is waiting for
 the write/read operation to complete, another thread can do some number
 crunching).

 If you really need to do this type of number crunching in Python
 level code, you'll want to look into the multiprocessing library
 instead. That will create actual OS processes (each with a copy of the
 interpreter, and not sharing memory) and each of those can run on a core
 without conflicting on the GIL.

Which library do you suggest?

 --
 Wulfraed Dennis Lee Bieber AF6VN
 wlfr...@ix.netcom.com HTTP://wlfraed.home.netcom.com/

 --
 http://mail.python.org/mailman/listinfo/python-list   
   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for philosophers

2013-05-18 Thread Chris Angelico
On Sun, May 19, 2013 at 9:56 AM, 8 Dihedral
dihedral88...@googlemail.com wrote:
 Hey, ChisA, are you delibrately to write a recursive version
 to demonstrate the stack depth problem in Python?

 def fact(n):
ret=1
if n1: # integer checking is not used but can be added
   for x in xrange(n): ret*=x
#print ret # debugging only for long integers
return ret



 In a 32 or 64 bit system, this non-recursive verssion
 will be limited by the heap space not by the stack limit.

And just when we're sure Dihedral's a bot, a post like this comes through.

Dihedral, are you intelligent? I'm still in two minds about this...
which may be why you so often appear to have no minds. I dunno.
Mathematics somewhere I fancy.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please help with Threading

2013-05-18 Thread Chris Angelico
On Sun, May 19, 2013 at 10:02 AM, Carlos Nepomuceno
carlosnepomuc...@outlook.com wrote:
 I didn't know Python threads aren't preemptive. Seems to be something really 
 old considering the state of the art on parallel execution on multi-cores.

 What's the catch on making Python threads preemptive? Are there any ongoing 
 projects to make that?

Preemption isn't really the issue here. On the C level, preemptive vs
cooperative usually means the difference between a stalled thread
locking everyone else out and not doing so. Preemption is done at a
lower level than user code (eg the operating system or the CPU),
meaning that user code can't retain control of the CPU.

With interpreted code eg in CPython, it's easy to implement preemption
in the interpreter. I don't know how it's actually done, but one easy
implementation would be every N bytecode instructions, context
switch. It's still done at a lower level than user code (N bytecode
instructions might all actually be a single tight loop that the
programmer didn't realize was infinite), but it's not at the OS level.

But none of that has anything to do with multiple core usage. The
problem there is that shared data structures need to be accessed
simultaneously, and in CPython, there's a Global Interpreter Lock to
simplify that; but the consequence of the GIL is that no two threads
can simultaneously execute user-level code. There have been
GIL-removal proposals at various times, but the fact remains that a
global lock makes a huge amount of sense and gives pretty good
performance across the board. There's always multiprocessing when you
need multiple CPU-bound threads; it's an explicit way to separate the
shared data (what gets transferred) from local (what doesn't).

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


mutable ints: I think I have painted myself into a corner

2013-05-18 Thread Cameron Simpson
TL;DR: I think I want to modify an int value in place.

Yesterday I was thinking about various flag set objects I have
floating around which are essentially bare objects whose attributes
I access, for example:

  flags = object()
  flags.this = True
  flags.that = False

and then elsewhere:

  if flags.that:
do that ...

Nice and readable, but I thought to myself: so bulky!

The use case for flags is essentially boolean/binary, and so a int
accessed as a bitmask should be smaller.

So I pulled out my BitMask int subclass (which mostly transcribes
the int as A|B|C for readability purposes, partly to dillute Nick
Coglan's liking for bulky strings over compact ints on readability
grounds:-), and gave the subclass attribute access.

This works just fine for querying the flags object, with code exactly
like the if statement above.

But setting up a flags object? What I _want_ to write is code like this:

  Flags = BitMask('this', 'that')

  # set default state
  flags = Flags()
  flags.this = False
  flags.that = True
  ... iterate over some options ...: flags.this = True

and there's my problem. This would modify the int in place. There's
no way to do that. For the base type (int) this makes perfect sense,
as they're immutable.

Before I toss this approach and retreat to my former object
technique, does anyone see a way forward to modify an int subclass
instance in place? (That doesn't break math, preferably; I don't
do arithmetic with these things but they are, after all, ints...)

Cheers,
-- 
Cameron Simpson c...@zip.com.au

Why does philosophy of consciousness/nature of reality seem to interest you
so much?  Take away consciousness and reality and there's not much left.
- Greg Egan, interview in Eidolon 15
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mutable ints: I think I have painted myself into a corner

2013-05-18 Thread Chris Angelico
On Sun, May 19, 2013 at 10:26 AM, Cameron Simpson c...@zip.com.au wrote:
 Before I toss this approach and retreat to my former object
 technique, does anyone see a way forward to modify an int subclass
 instance in place? (That doesn't break math, preferably; I don't
 do arithmetic with these things but they are, after all, ints...)


Why is it an int subclass? Because there are places where you want to
use it as though it were an int? It might be easier to render those,
instead, eg by creating a __int__ method. (Or is it an __int__
method? Not sure.)

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mutable ints: I think I have painted myself into a corner

2013-05-18 Thread Cameron Simpson
On 19May2013 11:11, Chris Angelico ros...@gmail.com wrote:
| On Sun, May 19, 2013 at 10:26 AM, Cameron Simpson c...@zip.com.au wrote:
|  Before I toss this approach and retreat to my former object
|  technique, does anyone see a way forward to modify an int subclass
|  instance in place? (That doesn't break math, preferably; I don't
|  do arithmetic with these things but they are, after all, ints...)
| 
| Why is it an int subclass? Because there are places where you want to
| use it as though it were an int? It might be easier to render those,
| instead, eg by creating a __int__ method. (Or is it an __int__
| method? Not sure.)

I don't want to use it as an int, on the outside. I want to use an
int on the inside as the implementation.

It's an int _subclass_ so that it is no bigger than an int. Otherwise
I may as well just make an ordinary object and be back where I
started.  Bulky:-(

The reason it is an _int_ subclass, versus something else, is that
a bitmap is a type of int. So the functional mapping is direct.

I _do_ _not_ want to operate on it from the outside as an int (doing
overt addition, for example, though I can imagine doing bitwise
activities); I want to operate on in _internally_ as a int to decide
what names-by-an-attribute flags are on or off.

So an object with an __int__() method is right out; it's the wrong
interface because it would mean an int() call (possibly implicit)
in exterior code.

Cheers,
-- 
Cameron Simpson c...@zip.com.au

Hoping to shave precious seconds off the time it would take me to get
through the checkout process and on my way home, I opted for the express
line (9 Items Or Less [sic]  Why nine items?  Where do they come up with
these rules, anyway?  It's the same way at most stores -- always some
oddball number like that, instead of a more understandable multiple of
five.  Like five.)
- Geoff Miller, geo...@purplehaze.corp.sun.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for philosophers

2013-05-18 Thread 88888 Dihedral
Chris Angelico於 2013年5月19日星期日UTC+8上午8時04分45秒寫道:
 On Sun, May 19, 2013 at 9:56 AM, 8 Dihedral
 
 dihedral88...@googlemail.com wrote:
 
  Hey, ChisA, are you delibrately to write a recursive version
 
  to demonstrate the stack depth problem in Python?
 
 
 
  def fact(n):
 
 ret=1
 
 if n1: # integer checking is not used but can be added
 
for x in xrange(n): ret*=x
 
 #print ret # debugging only for long integers
 
 return ret
 
 
 
 
 
 
 
  In a 32 or 64 bit system, this non-recursive verssion
 
  will be limited by the heap space not by the stack limit.
 
 
 
 And just when we're sure Dihedral's a bot, a post like this comes through.
 
 
 
 Dihedral, are you intelligent? I'm still in two minds about this...
 
 which may be why you so often appear to have no minds. I dunno.
 
 Mathematics somewhere I fancy.
 
 
 
 ChrisA

I am too lazy to write a factorial computations with primes
here.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to write fast into a file in python?

2013-05-18 Thread Dave Angel

On 05/18/2013 01:00 PM, Carlos Nepomuceno wrote:

Python really writes '\n\r' on Windows. Just check the files.


That's backwards.  '\r\n' on Windows, IF you omit the b in the mode when 
creating the file.




--
DaveA
--
http://mail.python.org/mailman/listinfo/python-list


Re: Future standard GUI library

2013-05-18 Thread llanitedave
I'm curious about how commonly tkinter is actually used among Python app 
developers as compared to wx, Pyside, or PyQT.  I get the impression that more 
distributed apps are built with wxPython, at least, than tkinter.  My 
impression is far from actual knowledge, of course.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please help with Threading

2013-05-18 Thread Cameron Simpson
On 19May2013 03:02, Carlos Nepomuceno carlosnepomuc...@outlook.com wrote:
| Just been told that GIL doesn't make things slower, but as I
| didn't know that such a thing even existed I went out looking for
| more info and found that document:
| http://www.dabeaz.com/python/UnderstandingGIL.pdf
| 
| Is it current? I didn't know Python threads aren't preemptive.
| Seems to be something really old considering the state of the art
| on parallel execution on multi-cores.
| What's the catch on making Python threads preemptive? Are there any ongoing 
projects to make that?

Depends what you mean by preemptive. If you have multiple CPU bound
pure Python threads they will all get CPU time without any of them
explicitly yeilding control. But thread switching happens between
python instructions, mediated by the interpreter.

The standard answers for using multiple cores is to either run
multiple processes (either explicitly spawning other executables,
or spawning child python processes using the multiprocessing module),
or to use (as suggested) libraries that can do the compute intensive
bits themselves, releasing the while doing so so that the Python
interpreter can run other bits of your python code.

Plenty of OS system calls (and calls to other libraries from the
interpreter) release the GIL during the call. Other python threads
can run during that window.

And there are other Python implementations other than CPython.

Cheers,
-- 
Cameron Simpson c...@zip.com.au

Processes are like potatoes.- NCR device driver manual
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: How to write fast into a file in python?

2013-05-18 Thread Carlos Nepomuceno

 Date: Sat, 18 May 2013 22:41:32 -0400
 From: da...@davea.name
 To: python-list@python.org
 Subject: Re: How to write fast into a file in python?

 On 05/18/2013 01:00 PM, Carlos Nepomuceno wrote:
 Python really writes '\n\r' on Windows. Just check the files.

 That's backwards. '\r\n' on Windows, IF you omit the b in the mode when
 creating the file.

Indeed! My mistake just made me find out that Acorn used that inversion on 
Acorn MOS.

According to this[1] (at page 449) the OSNEWL routine outputs '\n\r'.

What the hell those guys were thinking??? :p

OSNEWL
This call issues an LF CR (line feed, carriage return) to the currently selected
output stream. The routine is entered at FFE7.

[1] http://regregex.bbcmicro.net/BPlusUserGuide-1.07.pdf
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for philosophers

2013-05-18 Thread Michael Torrie
On 05/18/2013 08:30 PM, 8 Dihedral wrote:
 I am too lazy to write a factorial computations with primes
 here.

Ahh, that's better.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: How to write fast into a file in python?

2013-05-18 Thread Carlos Nepomuceno
Thanks Dan! I've never used CPython or PyPy. Will try them later.

I think the main difference between your create_file_numbers_file_like()
 and the fastwrite5.py I sent earlier is that I've used cStringIO 
instead of StringIO. It took 12s less using cStringIO.

My numbers are much greater, but I've used Python 2.7.5 instead:

C:\src\Pythonpython create_file_numbers.py
time taken to write a file of size 52428800  is  39.1199457743 seconds

time taken to write a file of size 52428800  is  14.8704800436 seconds

time taken to write a file of size 52428800  is  23.0011990985 seconds


I've downloaded bufsock.py and python2x3.py. The later one was hard to remove 
the source code from the web page.

Can I use them on my projects? I'm not used to the UCI license[1]. What's the 
difference to the GPL?




[1] http://stromberg.dnsalias.org/~dstromberg/UCI-license.html


 Date: Sat, 18 May 2013 12:38:30 -0700 
 Subject: Re: How to write fast into a file in python? 
 From: drsali...@gmail.com 
 To: lokeshkopp...@gmail.com 
 CC: python-list@python.org 
  
  
 With CPython 2.7.3: 
 ./t 
 time taken to write a file of size 52428800  is  15.86 seconds 
  
 time taken to write a file of size 52428800  is  7.91 seconds 
  
 time taken to write a file of size 52428800  is  9.64 seconds 
  
  
 With pypy-1.9: 
 ./t 
 time taken to write a file of size 52428800  is  3.708232 seconds 
  
 time taken to write a file of size 52428800  is  4.868304 seconds 
  
 time taken to write a file of size 52428800  is  1.93612 seconds 
  

 Here's the code: 
 #!/usr/local/pypy-1.9/bin/pypy 
 #!/usr/bin/python 
  
 import sys 
 import time 
 import StringIO 
  
 sys.path.insert(0, '/usr/local/lib') 
 import bufsock 
  
 def create_file_numbers_old(filename, size): 
  start = time.clock() 
  
  value = 0 
  with open(filename, w) as f: 
  while f.tell()  size: 
  f.write({0}\n.format(value)) 
  value += 1 
  
  end = time.clock() 
  
  print time taken to write a file of size, size,  is , (end  
 -start), seconds \n 
  
 def create_file_numbers_bufsock(filename, intended_size): 
  start = time.clock() 
  
  value = 0 
  with open(filename, w) as f: 
  bs = bufsock.bufsock(f) 
  actual_size = 0 
  while actual_size  intended_size: 
  string = {0}\n.format(value) 
  actual_size += len(string) + 1 
  bs.write(string) 
  value += 1 
  bs.flush() 
  
  end = time.clock() 
  
  print time taken to write a file of size, intended_size,  is ,  
 (end -start), seconds \n 
  
  
 def create_file_numbers_file_like(filename, intended_size): 
  start = time.clock() 
  
  value = 0 
  with open(filename, w) as f: 
  file_like = StringIO.StringIO() 
  actual_size = 0 
  while actual_size  intended_size: 
  string = {0}\n.format(value) 
  actual_size += len(string) + 1 
  file_like.write(string) 
  value += 1 
  file_like.seek(0) 
  f.write(file_like.read()) 
  
  end = time.clock() 
  
  print time taken to write a file of size, intended_size,  is ,  
 (end -start), seconds \n 
  
 create_file_numbers_old('output.txt', 50 * 2**20) 
 create_file_numbers_bufsock('output2.txt', 50 * 2**20) 
 create_file_numbers_file_like('output3.txt', 50 * 2**20) 
  
  
  
  
 On Thu, May 16, 2013 at 9:35 PM,  
 lokeshkopp...@gmail.commailto:lokeshkopp...@gmail.com wrote: 
 On Friday, May 17, 2013 8:50:26 AM UTC+5:30,  
 lokesh...@gmail.commailto:lokesh...@gmail.com wrote: 
  I need to write numbers into a file upto 50mb and it should be fast 
  
  can any one help me how to do that? 
  
  i had written the following code.. 
  
   
 ---
  
  
  def create_file_numbers_old(filename, size): 
  
  start = time.clock() 
  
  
  
  value = 0 
  
  with open(filename, w) as f: 
  
  while f.tell() size: 
  
  f.write({0}\n.format(value)) 
  
  value += 1 
  
  
  
  end = time.clock() 
  
  
  
  print time taken to write a file of size, size,  is , (end  
 -start), seconds \n 
  
   
 --
  
  
  it takes about 20sec i need 5 to 10 times less than that. 
 size = 50mb 
 -- 
 http://mail.python.org/mailman/listinfo/python-list 
  
  
 -- http://mail.python.org/mailman/listinfo/python-list
   
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: How to write fast into a file in python?

2013-05-18 Thread Carlos Nepomuceno
BTW, I've downloaded from the following places:

http://stromberg.dnsalias.org/svn/bufsock/trunk/bufsock.py
http://stromberg.dnsalias.org/~dstromberg/backshift/documentation/html/python2x3-pysrc.html

Are those the latest versions?


 From: carlosnepomuc...@outlook.com
 To: python-list@python.org
 Subject: RE: How to write fast into a file in python?
 Date: Sun, 19 May 2013 08:31:08 +0300
 CC: lokeshkopp...@gmail.com

 Thanks Dan! I've never used CPython or PyPy. Will try them later.

 I think the main difference between your create_file_numbers_file_like()
 and the fastwrite5.py I sent earlier is that I've used cStringIO
 instead of StringIO. It took 12s less using cStringIO.

 My numbers are much greater, but I've used Python 2.7.5 instead:

 C:\src\Pythonpython create_file_numbers.py
 time taken to write a file of size 52428800  is  39.1199457743 seconds

 time taken to write a file of size 52428800  is  14.8704800436 seconds

 time taken to write a file of size 52428800  is  23.0011990985 seconds


 I've downloaded bufsock.py and python2x3.py. The later one was hard to remove 
 the source code from the web page.

 Can I use them on my projects? I'm not used to the UCI license[1]. What's the 
 difference to the GPL?




 [1] http://stromberg.dnsalias.org/~dstromberg/UCI-license.html

 
 Date: Sat, 18 May 2013 12:38:30 -0700
 Subject: Re: How to write fast into a file in python?
 From: drsali...@gmail.com
 To: lokeshkopp...@gmail.com
 CC: python-list@python.org


 With CPython 2.7.3:
 ./t
 time taken to write a file of size 52428800 is 15.86 seconds

 time taken to write a file of size 52428800 is 7.91 seconds

 time taken to write a file of size 52428800 is 9.64 seconds


 With pypy-1.9:
 ./t
 time taken to write a file of size 52428800 is 3.708232 seconds

 time taken to write a file of size 52428800 is 4.868304 seconds

 time taken to write a file of size 52428800 is 1.93612 seconds


 Here's the code:
 #!/usr/local/pypy-1.9/bin/pypy
 #!/usr/bin/python

 import sys
 import time
 import StringIO

 sys.path.insert(0, '/usr/local/lib')
 import bufsock

 def create_file_numbers_old(filename, size):
 start = time.clock()

 value = 0
 with open(filename, w) as f:
 while f.tell()  size:
 f.write({0}\n.format(value))
 value += 1

 end = time.clock()

 print time taken to write a file of size, size,  is , (end
 -start), seconds \n

 def create_file_numbers_bufsock(filename, intended_size):
 start = time.clock()

 value = 0
 with open(filename, w) as f:
 bs = bufsock.bufsock(f)
 actual_size = 0
 while actual_size  intended_size:
 string = {0}\n.format(value)
 actual_size += len(string) + 1
 bs.write(string)
 value += 1
 bs.flush()

 end = time.clock()

 print time taken to write a file of size, intended_size,  is ,
 (end -start), seconds \n


 def create_file_numbers_file_like(filename, intended_size):
 start = time.clock()

 value = 0
 with open(filename, w) as f:
 file_like = StringIO.StringIO()
 actual_size = 0
 while actual_size  intended_size:
 string = {0}\n.format(value)
 actual_size += len(string) + 1
 file_like.write(string)
 value += 1
 file_like.seek(0)
 f.write(file_like.read())

 end = time.clock()

 print time taken to write a file of size, intended_size,  is ,
 (end -start), seconds \n

 create_file_numbers_old('output.txt', 50 * 2**20)
 create_file_numbers_bufsock('output2.txt', 50 * 2**20)
 create_file_numbers_file_like('output3.txt', 50 * 2**20)




 On Thu, May 16, 2013 at 9:35 PM,
 lokeshkopp...@gmail.commailto:lokeshkopp...@gmail.com wrote:
 On Friday, May 17, 2013 8:50:26 AM UTC+5:30,
 lokesh...@gmail.commailto:lokesh...@gmail.com wrote:
 I need to write numbers into a file upto 50mb and it should be fast

 can any one help me how to do that?

 i had written the following code..


 ---

 def create_file_numbers_old(filename, size):

 start = time.clock()



 value = 0

 with open(filename, w) as f:

 while f.tell() size:

 f.write({0}\n.format(value))

 value += 1



 end = time.clock()



 print time taken to write a file of size, size,  is , (end
 -start), seconds \n


 --

 it takes about 20sec i need 5 to 10 times less than that.
 size = 50mb
 --
 http://mail.python.org/mailman/listinfo/python-list


 -- http://mail.python.org/mailman/listinfo/python-list
 --
 http://mail.python.org/mailman/listinfo/python-list   
   
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue17997] ssl.match_hostname(): sub string wildcard should not match IDNA prefix

2013-05-18 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17997
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17989] ElementTree.Element broken attribute setting

2013-05-18 Thread Arfrever Frehtes Taifersar Arahesis

Arfrever Frehtes Taifersar Arahesis added the comment:

Replacement of pure-Python classes by C-accelerated classes is intentional.

http://docs.python.org/3.3/library/xml.etree.elementtree.html
Changed in version 3.3: This module will use a fast implementation whenever 
available. The xml.etree.cElementTree module is deprecated.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17989
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17989] ElementTree.Element broken attribute setting

2013-05-18 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


Removed file: http://bugs.python.org/file30301/ElementTree.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17989
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17973] '+=' on a list inside tuple both succeeds and raises an exception

2013-05-18 Thread Mark Dickinson

Mark Dickinson added the comment:

Another 'fix' would be to allow assignment to a tuple item in the case that the 
item being assigned is the same (in the sense of 'is') as the item already in 
the tuple.  Then the '+=' operation would succeed, but the tuple would remain 
immutable.

--
nosy: +mark.dickinson

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17973
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17998] internal error in regular expression engine

2013-05-18 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17998
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17973] '+=' on a list inside tuple both succeeds and raises an exception

2013-05-18 Thread Mark Dickinson

Mark Dickinson added the comment:

@andy.chugunov: tuples are immutable in the sense that you can't put a new 
object into a tuple or remove objects from a tuple.  That doesn't mean that 
tuples can't contain mutable objects, or prevent you from mutating the objects 
inside a tuple.

So the append method call is fine:  it's not modifying the tuple itself (the 
tuple still has references to exactly the same objects both before and after 
the append call);  it's merely mutating one the objects inside the tuple.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17973
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3489] add rotate{left,right} methods to bytearray

2013-05-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I think we can close. issue17100 would have been more useful actually.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3489
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17975] libpython3.so conflicts between $VERSIONs

2013-05-18 Thread Patrick Welche

Patrick Welche added the comment:

I see that this was introduced in

http://www.python.org/dev/peps/pep-0384/

Would a configure option to make it easy not to install the conflicting file be 
acceptable?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17975
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3489] add rotate{left,right} methods to bytearray

2013-05-18 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I think you rather need the inplace shift operation. Or even the move the tail 
of buffer to the start without filling the remaining. I.e. something like

buffer[:size] = buffer[-size:]

but without creating immediate bytes object. Now it may be written as:

buffer[:size] = memoryview(buffer)[-size:]

--
nosy: +serhiy.storchaka

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3489
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17975] libpython3.so conflicts between $VERSIONs

2013-05-18 Thread Arfrever Frehtes Taifersar Arahesis

Arfrever Frehtes Taifersar Arahesis added the comment:

See issue #11347. (Python ebuilds in Gentoo manually delete libpython3.so.)

--
nosy: +Arfrever

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17975
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18005] faster modular exponentiation in some cases

2013-05-18 Thread Pernici Mario

New submission from Pernici Mario:

A trivial optimization can be made in ``pow(a, b, c)``
if ``b`` is even and ``c - a  a``

```
In [1]: c = (1  100) + 1 

In [2]: a = c - 1234567

In [3]: b = 2

In [4]: %timeit pow(a, b, c)
1 loops, best of 3: 3.03 s per loop

In [5]: %timeit pow(c - a if c - a  (a  10) else a, b, c)
1000 loops, best of 3: 287 us per loop
```

This optimization is probably done in GMP, since using gmpy.mpz
[5] is a bit slower than [4].

--
messages: 189504
nosy: pernici
priority: normal
severity: normal
status: open
title: faster modular exponentiation in some cases
type: performance
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18005
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18005] faster modular exponentiation in some cases

2013-05-18 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
nosy: +eric.smith, lemburg, mark.dickinson, rhettinger, serhiy.storchaka, 
stutzbach
versions: +Python 3.4 -Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18005
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18005] faster modular exponentiation in some cases

2013-05-18 Thread Mark Dickinson

Mark Dickinson added the comment:

Sorry, I'm rejecting this.  This sort of micro-optimization for a little-used 
operation doesn't belong in Python.  For applications that need it, use gmpy2.

--
resolution:  - rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18005
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18000] _md5 should be built if _ssl cannot be built

2013-05-18 Thread Volker Braun

Volker Braun added the comment:

This has been fixed for Python-3.3 in #14693. Attached is a straightforward 
Python-2.7.5 backport of the patch.

--
keywords: +patch
nosy: +vbraun
Added file: http://bugs.python.org/file30304/hashlibfallbacks.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18000
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18006] Set thread nema in linux kernel

2013-05-18 Thread Марк Коренберг

New submission from Марк Коренберг:

In linux (Since 2.6.9) we can use syscall

prctl(PR_SET_NAME, Some thread name)

to set thread name to the kernel. This thread is seen  under this name in some 
process tool (like top, ps, pstree (have bug reported connected with this) and 
others).

It will be nice if this syscall will be called (from correspoding thread=TID) 
when changing (setting) thread name.

Note, that in current implementation name will be truncated to 15 bytes in 
kernel.

This work very well using ctypes or python-prctl module.

Also there is error in manpage about prctl saying that name is set to process 
(already sent to maintainer). Really, name is set to each thread.

--
components: Library (Lib)
messages: 189507
nosy: mmarkk
priority: normal
severity: normal
status: open
title: Set thread nema in linux kernel
type: enhancement
versions: Python 3.3, Python 3.4, Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18006
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17931] PyLong_FromPid() is not correctly defined on Windows 64-bit

2013-05-18 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


--
nosy: +mark.dickinson

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17931
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18006] Set thread name in linux kernel

2013-05-18 Thread Марк Коренберг

Changes by Марк Коренберг socketp...@gmail.com:


--
title: Set thread nema in linux kernel - Set thread name in linux kernel

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18006
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17975] libpython3.so conflicts between $VERSIONs

2013-05-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Did you use make altinstall?

--
nosy: +barry, dmalcolm, pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17975
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18004] test_list.test_overflow crashes Win64

2013-05-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I take it you have more than 16GB of RAM?
What happens if you replace sys.maxint with sys.maxsize in test_overflow?

--
nosy: +arigo, pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18004
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18004] test_list.test_overflow crashes Win64

2013-05-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Note: test_overflow can be found in Python2.7/Lib/test/test_list.py

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18004
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17807] Generator cleanup without tp_del

2013-05-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Obsoleted by PEP 442.

--
resolution:  - rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17807
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18006] Set thread name in linux kernel

2013-05-18 Thread R. David Murray

R. David Murray added the comment:

This is effectively a duplicate of issue 5672.  Are you interested in carrying 
through the process outlined there by Martin?  Otherwise we should close this 
issue as well until someone does propose to do so.

--
nosy: +r.david.murray
versions:  -Python 3.3, Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18006
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18004] test_list.test_overflow crashes Win64

2013-05-18 Thread Armin Rigo

Changes by Armin Rigo ar...@users.sourceforge.net:


--
nosy:  -arigo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18004
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18006] Set thread name in linux kernel

2013-05-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I'd also point out that changing the kernel thread name *by default* would be 
pretty much a large regression.

--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18006
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17989] ElementTree.Element broken attribute setting

2013-05-18 Thread Eli Bendersky

Changes by Eli Bendersky eli...@gmail.com:


--
assignee:  - eli.bendersky

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17989
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17997] ssl.match_hostname(): sub string wildcard should not match IDNA prefix

2013-05-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Actually, I don't this is a bug: match_hostname() expects str data, and 
therefore IDNA-decoded domain names:

 bxn--gtter-jua.example.de.decode(idna)
'götter.example.de'

Doing the matching on the decoded domain name should be safe.
Then it very much depends on whether the data you've got was IDNA-decoded, or 
naïvely ASCII-decoded, and I don't think the Python stdlib is very consistent 
here. Looking at the socket module, gethostbyaddr and getnameinfo seem to use 
ASCII decoding...

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17997
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17989] ElementTree.Element broken attribute setting

2013-05-18 Thread Eli Bendersky

Eli Bendersky added the comment:

Yes, overwriting the Python classes with C classes is not an error, but the 
original issue is legit. The error should be more immediately reported.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17989
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15758] FileIO.readall() has worst case O(n^2) complexity

2013-05-18 Thread Richard Oudkerk

Changes by Richard Oudkerk shibt...@gmail.com:


--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15758
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17997] ssl.match_hostname(): sub string wildcard should not match IDNA prefix

2013-05-18 Thread Christian Heimes

Christian Heimes added the comment:

It's called internationalized domain name for APPLICATIONS. ;) It's up to the 
application to interpret the ASCII text as IDNA encoded FQDNs. As far as I know 
DNS, SSL's CNAME and OS interfaces etc. always use ASCII labels. It's an 
elegant solution. Just the UI part of an application needs to understand IDNA. 

http://tools.ietf.org/html/rfc6125#section-6.4.2

   If the DNS domain name portion of a reference identifier is an
   internationalized domain name, then an implementation MUST convert
   any U-labels [IDNA-DEFS] in the domain name to A-labels before
   checking the domain name.  In accordance with [IDNA-PROTO], A-labels
   MUST be compared as case-insensitive ASCII.  Each label MUST match in
   order for the domain names to be considered to match, except as
   supplemented by the rule about checking of wildcard labels
   (Section 6.4.3; but see also Section 7.2 regarding wildcards in
   internationalized domain names).


Coincidentally the same RFC contains matching rules for wild card certs 
http://tools.ietf.org/html/rfc6125#section-6.4.3

   If a client matches the reference identifier against a presented
   identifier whose DNS domain name portion contains the wildcard
   character '*', the following rules apply:

   1.  The client SHOULD NOT attempt to match a presented identifier in
   which the wildcard character comprises a label other than the
   left-most label (e.g., do not match bar.*.example.net).

   2.  If the wildcard character is the only character of the left-most
   label in the presented identifier, the client SHOULD NOT compare
   against anything but the left-most label of the reference
   identifier (e.g., *.example.com would match foo.example.com but
   not bar.foo.example.com or example.com).

   3.  The client MAY match a presented identifier in which the wildcard
   character is not the only character of the label (e.g.,
   baz*.example.net and *baz.example.net and b*z.example.net would
   be taken to match baz1.example.net and foobaz.example.net and
   buzz.example.net, respectively).  However, the client SHOULD NOT
   attempt to match a presented identifier where the wildcard
   character is embedded within an A-label or U-label [IDNA-DEFS] of
   an internationalized domain name [IDNA-PROTO].

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17997
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-18 Thread Christian Heimes

Christian Heimes added the comment:

The IDNA RFC contains additional rules for wildcard matching ... very well 
hidden indead!

http://tools.ietf.org/html/rfc6125#section-6.4.3

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17980
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17989] ElementTree.Element broken attribute setting

2013-05-18 Thread Eli Bendersky

Eli Bendersky added the comment:

The problem is that element_setattro is returning a wrong value for error - 
NULL instead of -1. So the exception is set and is triggered on the next line 
instead. Will fix for 3.3 and default branches

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17989
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17989] ElementTree.Element broken attribute setting

2013-05-18 Thread Eli Bendersky

Changes by Eli Bendersky eli...@gmail.com:


--
stage:  - needs patch
type:  - behavior

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17989
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18002] AMD64 Windows7 SP1 3.x buildbot: compilation of _ssl module fails, the build fails

2013-05-18 Thread Jeremy Kloth

Jeremy Kloth added the comment:

The build of OpenSSL was failing due to an incomplete external check-in of 
OpenSSL (missing the cached assembler files).

Martin has since updated the external and I have refreshed the OpenSSL exports 
on the buildbot.  It is no longer failing to compile, but other errors still 
remain.

This issue can be closed.

--
nosy: +jkloth
type:  - compile error

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18002
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17989] ElementTree.Element broken attribute setting

2013-05-18 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 9682241dc8fc by Eli Bendersky in branch '3.3':
Issue #17989: element_setattro returned incorrect error value.
http://hg.python.org/cpython/rev/9682241dc8fc

New changeset b111ae4f83ef by Eli Bendersky in branch 'default':
Issue #17989: element_setattro returned incorrect error value.
http://hg.python.org/cpython/rev/b111ae4f83ef

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17989
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17989] ElementTree.Element broken attribute setting

2013-05-18 Thread Eli Bendersky

Eli Bendersky added the comment:

Fixed. Thanks for the report!

Python 3.4.0a0 (default:1b760f926846+9682241dc8fc+, May 18 2013, 07:52:49) 
[GCC 4.6.3] on linux
Type help, copyright, credits or license for more information.
 import xml.etree.ElementTree as ET; j = ET.Element('j')
 j.ham = 2
Traceback (most recent call last):
  File stdin, line 1, in module
AttributeError: Can't set arbitraty attributes on Element


--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17989
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17989] ElementTree.Element broken attribute setting

2013-05-18 Thread Eli Bendersky

Changes by Eli Bendersky eli...@gmail.com:


--
resolution:  - fixed
stage: needs patch - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17989
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17988] ElementTree.Element != ElementTree._ElementInterface

2013-05-18 Thread Eli Bendersky

Eli Bendersky added the comment:

These compatibility names are likely to be remnants from the out-of-tree xml 
etree implementation before it made it into the stdlib. I think they can simply 
be removed in 3.4, as they're not documented anywhere.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17988
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18007] CookieJar expects request objects with origin_req_host attribute instead of method

2013-05-18 Thread Simon Nicolussi

New submission from Simon Nicolussi:

A fix for a DeprecationWarning (#17678) had the unfortunate side effect of 
changing the expected interface of the request object higher up in the call 
stack.

For example, the documentation for CookieJar.add_cookie_header(request) states 
that the request object must support the methods get_full_url(), get_host(), 
get_type(), unverifiable(), get_origin_req_host(), has_header(), get_header(), 
header_items(), and add_unredirected_header(). The patch for #17678, however, 
changes the requirement for a get_origin_req_host() method to an 
origin_req_host attribute.

This breaks at least one notable third-party library (Kenneth Reitz' Requests).

--
assignee: docs@python
components: Documentation, Library (Lib)
messages: 189523
nosy: docs@python, orsenthil, sinic
priority: normal
severity: normal
status: open
title: CookieJar expects request objects with origin_req_host attribute instead 
of method
type: behavior
versions: Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18007
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18008] python33-3.3.2 Parser/pgen: Permission denied

2013-05-18 Thread William Moreno

New submission from William Moreno:

cc -DNDEBUG -O2 -pipe  -fno-strict-aliasing -pthread  -pthread Parser/acceler.o 
 Parser/grammar1.o  Parser/listnode.o  Parser/node.o  Parser/parser.o  
Parser/bitset.o  Parser/metagrammar.o  Parser/firstsets.o  Parser/grammar.o  
Parser/pgen.o Objects/obmalloc.o  Python/dynamic_annotations.o  
Python/mysnprintf.o  Python/pyctype.o  Parser/tokenizer_pgen.o  
Parser/printgrammar.o  Parser/parsetok_pgen.o  Parser/pgenmain.o -lutil -o 
Parser/pgen
`Parser/pgen' is up to date.
Parser/pgen ./../Grammar/Grammar Include/graminit.h Python/graminit.c
Parser/pgen: Permission denied
*** [Include/graminit.h] Error code 126
cc -c  -DNDEBUG -O2 -pipe  -fno-strict-aliasing -O2 -pipe  -fno-strict-aliasing 
-O2 -pipe  -fno-strict-aliasing-I. -IInclude -I./../Include
-DPy_BUILD_CORE -o Objects/typeobject.o ./../Objects/typeobject.c
/usr/lib/crt1.o: In function `_start':
crt1.c:(.text+0x8a): undefined reference to `main'
Parser/bitset.o: In function `_Py_newbitset':
bitset.c:(.text+0xfa): undefined reference to `Py_FatalError'
Parser/firstsets.o: In function `calcfirstset':
firstsets.c:(.text+0x15): undefined reference to `Py_DebugFlag'
firstsets.c:(.text+0x1d9): undefined reference to `Py_DebugFlag'
firstsets.c:(.text+0x20f): undefined reference to `Py_FatalError'
firstsets.c:(.text+0x329): undefined reference to `Py_FatalError'
Parser/firstsets.o: In function `_Py_addfirstsets':
firstsets.c:(.text+0x345): undefined reference to `Py_DebugFlag'
Parser/grammar.o: In function `_Py_translatelabels':
grammar.c:(.text+0x87): undefined reference to `Py_DebugFlag'
grammar.c:(.text+0x10d): undefined reference to `Py_DebugFlag'
grammar.c:(.text+0x205): undefined reference to `Py_DebugFlag'
grammar.c:(.text+0x234): undefined reference to `Py_DebugFlag'
Parser/grammar.o: In function `_Py_findlabel':
grammar.c:(.text+0x452): undefined reference to `Py_FatalError'
Parser/grammar.o: In function `_Py_addarc':
grammar.c:(.text+0x4ec): undefined reference to `Py_FatalError'
Parser/grammar.o: In function `_Py_addstate':
grammar.c:(.text+0x588): undefined reference to `Py_FatalError'
Parser/grammar.o: In function `_Py_addlabel':
grammar.c:(.text+0x63b): undefined reference to `Py_DebugFlag'
grammar.c:(.text+0x675): undefined reference to `Py_FatalError'
Parser/grammar.o: In function `_Py_adddfa':
grammar.c:(.text+0x72e): undefined reference to `Py_FatalError'
Parser/grammar.o: In function `_Py_newgrammar':
grammar.c:(.text+0x7a6): undefined reference to `Py_FatalError'
Parser/pgen.o: In function `addnfaarc':
pgen.c:(.text+0x76): undefined reference to `Py_FatalError'
Parser/pgen.o: In function `addnfastate':
pgen.c:(.text+0xd6): undefined reference to `Py_FatalError'
Parser/pgen.o: In function `_Py_pgen':
pgen.c:(.text+0x5f4): undefined reference to `Py_DebugFlag'
pgen.c:(.text+0x744): undefined reference to `Py_FatalError'
pgen.c:(.text+0x799): undefined reference to `Py_FatalError'
pgen.c:(.text+0x7ee): undefined reference to `Py_DebugFlag'
pgen.c:(.text+0xaa3): undefined reference to `Py_DebugFlag'
pgen.c:(.text+0xb86): undefined reference to `Py_DebugFlag'
pgen.c:(.text+0xc96): undefined reference to `Py_FatalError'
pgen.c:(.text+0xca5): undefined reference to `Py_FatalError'
pgen.c:(.text+0xcb1): undefined reference to `Py_DebugFlag'
pgen.c:(.text+0xeed): undefined reference to `Py_FatalError'
pgen.c:(.text+0xefc): undefined reference to `Py_FatalError'
Parser/tokenizer_pgen.o: In function `indenterror':
tokenizer_pgen.c:(.text+0x3a6): undefined reference to `PySys_WriteStderr'
Parser/tokenizer_pgen.o: In function `tok_nextc':
tokenizer_pgen.c:(.text+0x605): undefined reference to `PyOS_Readline'
tokenizer_pgen.c:(.text+0x6ef): undefined reference to `PySys_WriteStderr'
Parser/tokenizer_pgen.o: In function `tok_backup':
tokenizer_pgen.c:(.text+0xa98): undefined reference to `Py_FatalError'
Parser/parsetok_pgen.o: In function `PyParser_ParseStringFlagsFilenameEx':
parsetok_pgen.c:(.text+0x5e3): undefined reference to `PyErr_Occurred'
*** [Parser/pgen] Error code 1
1 error
*** [Include/graminit.h] Error code 2
1 error
*** [Python/importlib.h] Error code 2
2 errors
*** [do-build] Error code 1

Stop in /usr/ports/lang/python33.
*** [install] Error code 1

Stop in /usr/ports/lang/python33.
root@server:/usr/ports/lang/python33 # make clean
===  Cleaning for python33-3.3.2

--
components: Build
messages: 189524
nosy: wmoreno3
priority: normal
severity: normal
status: open
title: python33-3.3.2 Parser/pgen: Permission denied
type: compile error
versions: Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18008
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-18 Thread Roundup Robot

Roundup Robot added the comment:

New changeset b9b521efeba3 by Antoine Pitrou in branch '3.2':
Issue #17980: Fix possible abuse of ssl.match_hostname() for denial of service 
using certificates with many wildcards (CVE-2013-2099).
http://hg.python.org/cpython/rev/b9b521efeba3

New changeset c627638753e2 by Antoine Pitrou in branch '3.3':
Issue #17980: Fix possible abuse of ssl.match_hostname() for denial of service 
using certificates with many wildcards (CVE-2013-2099).
http://hg.python.org/cpython/rev/c627638753e2

New changeset fafd33db6ff6 by Antoine Pitrou in branch 'default':
Issue #17980: Fix possible abuse of ssl.match_hostname() for denial of service 
using certificates with many wildcards (CVE-2013-2099).
http://hg.python.org/cpython/rev/fafd33db6ff6

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17980
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Ok, this should be fixed now. Thanks a lot for reporting!

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17980
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17997] ssl.match_hostname(): sub string wildcard should not match IDNA prefix

2013-05-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 It's called internationalized domain name for APPLICATIONS. ;) It's 
 up to the application to interpret the ASCII text as IDNA encoded
 FQDNs. As far as I know DNS, SSL's CNAME and OS interfaces etc. always 
 use ASCII labels. It's an elegant solution. Just the UI part of an
 application needs to understand IDNA. 

The socket module already decodes to/encodes from IDNA in places (e.g. 
gethostname()). We need a consistent policy in the stdlib; I would like 
Martin's advice on this.

--
nosy: +loewis

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17997
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18002] AMD64 Windows7 SP1 3.x buildbot: compilation of _ssl module fails, the build fails

2013-05-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Thanks for the heads-up. Closing.

--
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18002
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3489] add rotate{left,right} methods to bytearray

2013-05-18 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
resolution:  - rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3489
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17953] sys.modules cannot be reassigned

2013-05-18 Thread Yogesh Chaudhari

Yogesh Chaudhari added the comment:

Documentation added for sys.modules

--
keywords: +patch
nosy: +Yogesh.Chaudhari
Added file: http://bugs.python.org/file30305/issue17953.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17953
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17998] internal error in regular expression engine

2013-05-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Perhaps it would be safer to revert the original commit in bugfix branches, and 
just commit the better patch in default?

--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17998
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17975] libpython3.so conflicts between $VERSIONs

2013-05-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

According to Martin on the bug linked to:

« Having the soname be libpython3 is the whole point of the library, it serves 
no other reason.

It is intentional that there are file collisions with that file, and either the 
local admin or the distributor must make an explicit choice which libpython3 
should be installed; it should be the one that corresponds to /usr/bin/python 
(if you install it into /usr/lib). »

Should we close this issue as won't fix?

--
nosy: +loewis

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17975
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17975] libpython3.so conflicts between $VERSIONs

2013-05-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

(on the bug Arfrever linked to, sorry)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17975
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >