Re: Question about Source Control

2014-03-18 Thread Chris Angelico
On Tue, Mar 18, 2014 at 4:39 PM, Frank Millman fr...@chagford.com wrote:
 Two quick questions -

 1. At present the source code is kept on one machine (A), but only accessed
 from the two other machines (B and C).

 Does it make sense to create the central repository on A, but *not* install
 the SCM on A? Install separate copies of the SCM on B and C, and allow them
 both to set up their own clones. I only develop on B, so only B would
 'push', but both B and C would 'pull' to get the latest version.

I don't know about Mercurial, but with git, installing the software on
A lets it work more efficiently (otherwise it has to do all the work
remotely, ergo unnecessary traffic). Advantage of free software is
that you don't have to check license agreements - just go ahead,
install it everywhere. But if for some reason that would be a problem,
you can look into running it over basic SSH or something.

 2. Being a typical lazy programmer, I frequently go through the following
 cycle. I work on a section of code by editing it on B. Then I test it by
 running it on C. Instead of meticulously checking my code I let python find
 the errors, so I run it on C, it crashes with a traceback, I fix the error
 on B and rerun it on C until it is working to my satisfaction.

 It seems that I will have to change my approach. Edit on B, 'push' on B,
 'pull' on C, run from C. It sounds more cumbersome, but maybe that is the
 price I have to pay.

 Have I got those two right?

That would be the simplest to set up. But here are two alternatives:

1) My current setup for developing Gypsum involves development on
Sikorsky, on Linux, and everything gets tested there. Then every once
in a while, I pull changes to Traal, and test on Windows. If there's a
problem, that's a separate commit fixing a separate issue (Implement
pause key handling / Fix pause key handling on Windows). That works
fairly well when you can do 90% of your testing on your development
box.

2) At work, we had a system for rapid development across two machines,
pretty much how you're describing. To make that work, I wrote a
three-part rapid send/receive system: a daemon that runs on the dev
system, a client that runs on the test system and connects to the
daemon, and a triggering notification that runs on the dev and tells
the daemon to do its work. (That could be done with a process signal,
but I wanted to send it some parameters.) When the daemon gets
notified to send its stuff across, it writes out the full content of
all changed files (mangled somewhat because my boss was paranoid -
well, as far as I know he's still utterly paranoid, but he's not my
boss any more) to the socket connection, and the receiver plops them
onto the disk and SIGHUPs the appropriate processes to tell them to
reload code.

The second option takes some setting up, though I'd be happy to help
out with the code. But it's really easy to use. You shoot stuff across
to it and off it all goes. The way I described above, it's quite happy
to have multiple simultaneous clients, and it's happy for those
clients to be behind NAT - so you can run half a dozen VMs with
different configurations, and have them all get the code together. And
you can put the trigger into a makefile to be run at the end of some
other tasks, or have it do some sanity checking, or whatever you like.
Very flexible and powerful.

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


Re: Question about Source Control

2014-03-18 Thread Frank Millman

Chris Angelico ros...@gmail.com wrote in message 
news:captjjmqhxh2m3-qgbelv_akgajzmeymbudly8_dkpnhrpsu...@mail.gmail.com...
 On Tue, Mar 18, 2014 at 4:39 PM, Frank Millman fr...@chagford.com wrote:
 Two quick questions -

 1. At present the source code is kept on one machine (A), but only 
 accessed
 from the two other machines (B and C).

 Does it make sense to create the central repository on A, but *not* 
 install
 the SCM on A? Install separate copies of the SCM on B and C, and allow 
 them
 both to set up their own clones. I only develop on B, so only B would
 'push', but both B and C would 'pull' to get the latest version.

 I don't know about Mercurial, but with git, installing the software on
 A lets it work more efficiently (otherwise it has to do all the work
 remotely, ergo unnecessary traffic). Advantage of free software is
 that you don't have to check license agreements - just go ahead,
 install it everywhere. But if for some reason that would be a problem,
 you can look into running it over basic SSH or something.


Excuse my ignorance, but how does it actually work?

Do you set up some kind of client/server relationship, and if so, how do the 
clients (machines B and C) access the software on machine A?

I know that Mercurial can run its own web server, and clients can access it 
through http. It that what you are suggesting? That would be quite a change 
for me, as on my linux box I do all my work from the command line on a 
console.

These are the kind of stumbling blocks that prevented me from succeeding in 
my previous attempt. I have a vague recollection that I set it up on machine 
A, but then hit a problem because machines B and C both accessed the same 
directory, but with different names - on Windows, a mapped drive and on 
linux a mounted nfs directory. I had to provide a 'path' name to set up 
Mercurial in the first place, but I could not find one that suited both 
clients.

I feel that I have just not grasped the basics yet, so any assistance that 
puts me on the right path is appreciated.

Frank



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


Re: Question about Source Control

2014-03-18 Thread Ben Finney
Frank Millman fr...@chagford.com writes:

 I feel that I have just not grasped the basics yet, so any assistance that 
 puts me on the right path is appreciated.

Here is “Hg Init”, a tutorial for Mercurial URL:http://hginit.com/.

(“source control” is not the most common term for this; what we're
talking about is a “version control system”, or VCS. But some Git users
may disagree.)

-- 
 \ “If nature has made any one thing less susceptible than all |
  `\others of exclusive property, it is the action of the thinking |
_o__)  power called an idea” —Thomas Jefferson |
Ben Finney

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


Re: Question about Source Control

2014-03-18 Thread Frank Millman

Andriy Kornatskyy andriy.kornats...@live.com wrote in message 
news:blu0-smtp953c8572b5ca6374830e5091...@phx.gbl...
 Frank,

 I would suggest start with an account on https://bitbucket.org. It 
 supports private repositories so you should be good there.

 From other hand you can setup own infrastructure for SCM, read more here:
 http://mindref.blogspot.com/2013/10/how-to-manage-git-or-mercurial.html


Thanks, Andriy.

I followed your link, which took me to another link which took me to 
RhodeCode - https://rhodecode.com/

It looks interesting. I wll investigate that and bitbucket further.

Frank



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


Re: 'complex' function with string argument.

2014-03-18 Thread Christian Gollwitzer

Am 15.03.14 17:26, schrieb Jayanth Koushik:

This is regarding the inbuilt 'complex' function. The python docs
say: Note: When converting from a string, the string must not
contain whitespace around the central + or - operator. For example,
complex('1+2j') is fine, but complex('1 + 2j') raises ValueError.


It's funny that you ask this question exactly now; because I'm currently 
implementing a compiler for a small language that understands complex 
numbers. As others have explained, the basic issue is the question how 
to parse an expression like


1+2i*3

is it complex(1+2i) times 3 or is it sum of 1 and product of complex 
2i and 3? The answer that python does it by parsing imaginary literals 
and then combining them back using peephole optimization was helpful, 
thanks for that!


Christian
--
https://mail.python.org/mailman/listinfo/python-list


Re: Question about Source Control

2014-03-18 Thread Chris Angelico
On Tue, Mar 18, 2014 at 5:42 PM, Frank Millman fr...@chagford.com wrote:
 Excuse my ignorance, but how does it actually work?

Ignorance not only excused, but welcomed. :) However, caveat: I know
how git is set up, but not hg. Someone else can fill in the details;
for now, I'll explain git and hope that hg is broadly similar. I
expect it will be.

 Do you set up some kind of client/server relationship, and if so, how do the
 clients (machines B and C) access the software on machine A?

For read-only access, git can run its own protocol, but for read/write
it's most common to run it over SSH. Every pull or push is implemented
by git calling on ssh to run either 'git send-pack' or 'git
receive-pack' on the other end. (It's common to set it up with a
restricted shell that can *only* run those commands, although I also
find this usage convenient for cloning between two computers that I
control, rather than fetching from upstream. It's immensely faster
downloading something over a virtualized gigabit ethernet link than
over the internet!)

So it goes by the rules of SSH. There's a user account on the target
computer, which owns all the files in the repository. That user
account might have a password on it (which you type in every time you
pull/push), or you might use public/private keys to authenticate, or
whatever else you've set up. That part isn't git's responsibility. On
Linux systems, it's usually pretty easy to set up openssh and a
dedicated account; on other servers, I assume it can't be hard to get
something going.

 I know that Mercurial can run its own web server, and clients can access it
 through http. It that what you are suggesting? That would be quite a change
 for me, as on my linux box I do all my work from the command line on a
 console.

You'd still do everything from the command line. You type git clone
blahblah or hg clone blahblah, and everything happens under the
covers. The only way you'd know the difference is if the blahblah
part identifies the protocol (which it usually will, but that's
somewhat beside the point).

 These are the kind of stumbling blocks that prevented me from succeeding in
 my previous attempt. I have a vague recollection that I set it up on machine
 A, but then hit a problem because machines B and C both accessed the same
 directory, but with different names - on Windows, a mapped drive and on
 linux a mounted nfs directory. I had to provide a 'path' name to set up
 Mercurial in the first place, but I could not find one that suited both
 clients.

 I feel that I have just not grasped the basics yet, so any assistance that
 puts me on the right path is appreciated.

Yeah, a distributed repository solves that. You could have three
entirely different path names on the three computers, and nothing will
care. (You have to be careful to use relative paths everywhere
internally, of course, but you probably do that already.) It's pretty
efficient once you get used to it; I recommend poking around on the
internet for a git tutorial or an hg tutorial, depending on which you
go with. It's not too hard, but there are a lot of commands to keep
track of. Here's a helpful quick reference to the differences between
the two:

https://github.com/sympy/sympy/wiki/Git-hg-rosetta-stone

As a git-familiar and hg-novice, I keep that handy every time I'm
working with hg on anything more complicated than keep up with the
changes.

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


Re: 'complex' function with string argument.

2014-03-18 Thread Chris Angelico
On Tue, Mar 18, 2014 at 6:04 PM, Christian Gollwitzer aurio...@gmx.de wrote:
 As others have explained, the basic issue is the question how to parse an
 expression like

 1+2i*3

 is it complex(1+2i) times 3 or is it sum of 1 and product of complex 2i
 and 3?

The only way to have it be the former would be to mandate that all
complex literals have both parts, and you'd still lose clarity. You'd
probably want to have some other symbol rather than + in there, to
emphasize the connection:

1_2j
1_--2j # Negative imaginary component

Otherwise, yeah, do what Python does and have imaginary literals only.

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


Re: Question about Source Control

2014-03-18 Thread Frank Millman

Ben Finney ben+pyt...@benfinney.id.au wrote in message 
news:85y508roiw@benfinney.id.au...
 Frank Millman fr...@chagford.com writes:

 I feel that I have just not grasped the basics yet, so any assistance 
 that
 puts me on the right path is appreciated.

 Here is Hg Init, a tutorial for Mercurial URL:http://hginit.com/.

 (source control is not the most common term for this; what we're
 talking about is a version control system, or VCS. But some Git users
 may disagree.)


Thanks, Ben, that is a really nice tutorial.

I was calling it an SCM because that is how Mercurial describes it - from 
their home page Mercurial is a free, distributed source managment control 
tool. I do agree that 'version control' makes more sense.

Frank



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


Re: Question about Source Control

2014-03-18 Thread Chris Angelico
On Tue, Mar 18, 2014 at 5:47 PM, Ben Finney ben+pyt...@benfinney.id.au wrote:
 (“source control” is not the most common term for this; what we're
 talking about is a “version control system”, or VCS. But some Git users
 may disagree.)

People use different terms depending on their backgrounds, I think.
I've heard a good few words used to describe fundamentally the same
thing, and none is really perfect.

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


Re: Ordering in the printout of a dictionary

2014-03-18 Thread Marc Christiansen
Chris Angelico ros...@gmail.com wrote:
 On Tue, Mar 18, 2014 at 11:32 AM, Mok-Kong Shen
 mok-kong.s...@t-online.de wrote:
 Is there a way to force a certain ordering of the printout or else
 somehow manage to get at least a certain stable ordering of the
 printout (i.e. input and output are identical)?
 
 Yes; instead of simply printing it out (which calls repr()),
 explicitly iterate over it, like this:
 
 def display(d):
return '{'+','.join('%r: %r'%(key,d[key]) for key in sorted(d))+'}'
 
[...]
 At least, it's consistent as long as the keys all sort consistently,
 which they will if you use simple strings. Other types of keys may not
 work, and in fact mixing types may cause an exception:
 
 print(display({True:1,Hello:2}))
 Traceback (most recent call last):
  File stdin, line 1, in module
  File stdin, line 2, in display
 TypeError: unorderable types: str()  bool()
 
 But for strings, this is the easiest way to get what you're looking for.

I would say using pprint.pprint is even easier and it works with your
failing example:

 pprint.pprint({True:1,Hello:2})
{True: 1, 'Hello': 2}

Ciao
Marc
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Balanced trees

2014-03-18 Thread Joshua Landau
On 18 March 2014 01:01, Daniel Stutzbach stutzb...@google.com wrote:
 I would love to have include macro-benchmarks.  I keep waiting for the PyPy
 benchmark suite to get ported to Python 3...

*grins*

 Delete a slice is fudged from its inclusion of multiplication, which
 is far faster on blists. I admit that it's not obvious how to fix
 this.

 I could move the initialization into the timed part, similar to what I did
 for sort (see below).  That has downsides too, of course, but it might be an
 improvement.

You could try making a baseline and subtracting it:

timer(del x[len(x)//4:3*len(x)//4]; x *= 2) - timer(x * 2)

Not ideal, but closer, assuming that the multiplication isn't much
larger than the deletion. Error would be summed.

 Sort * are really unfair because they put initialisation in the
 timed part

 That's a limitation of timeit.  The setup step is only executed once.  If I
 put the initialization there, every sort after the first one would be
 sorting a pre-sorted list.  If you compare the Create form an iterator and
 Sort a random list, you'll see that the initialization cost is dwarfed by
 the sorting cost for n  15 or so.

This argument is slightly less convincing without the overhead of the
keys. It might be worth doing a subtraction and adding some error-bars
as I suggest above. Nevertheless, I do agree for n  some small n,
which is all that matters anyway.

 and all have keys.

 If you use classes with __lt__ methods instead of keys, the cost is
 dominated by the calls to __lt__.  You're right that I should include both,
 though.

This argument doesn't make sense to me. The only time this happens is
when you have a non-primitive and your transformation gives a
primitive which has optimised comparisons. This typically only happens
when the key is a getitem or getattr, in which case it's just
meaningless overhead. I see little reason to care about the key's cost
in those cases.

 That's definitely a cache issue, which is always a risk with
 micro-benchmarks.

 I agree it's more interesting to pick items randomly instead of always
 querying the same index.  The overhead of choice() is kind of a problem,
 though.  Since I'm only plotting up to 10**5, I'd expect these to look more
 or less flat.

You could try jumping around to avoid the cache without using random
numbers. Something like idx = (idx + LARGE_PRIME) % n might have less
overhead. Further, the subtraction method would probably work fine for
that.

Also, I don't think the cache is all bad. Chances are a lot of list
accesses have a lot of data locality.

 Thanks for all of the feedback.

Thanks in turn for the module :).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ordering in the printout of a dictionary

2014-03-18 Thread Chris Angelico
On Tue, Mar 18, 2014 at 6:36 PM, Marc Christiansen
usenetm...@solar-empire.de wrote:
 I would say using pprint.pprint is even easier and it works with your
 failing example:

 pprint.pprint({True:1,Hello:2})
 {True: 1, 'Hello': 2}


True. I could try to say that I prefer to offer the simpler approach
rather than encourage people to automatically reach for the nearest
hammer and hope it's right, but the fact is... I completely forgot
about pprint :)

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


Re: Question about Source Control

2014-03-18 Thread Steven D'Aprano
On Tue, 18 Mar 2014 17:47:51 +1100, Ben Finney wrote:

 Frank Millman fr...@chagford.com writes:
 
 I feel that I have just not grasped the basics yet, so any assistance
 that puts me on the right path is appreciated.
 
 Here is “Hg Init”, a tutorial for Mercurial URL:http://hginit.com/.
 
 (“source control” is not the most common term for this; what we're
 talking about is a “version control system”, or VCS. But some Git users
 may disagree.)

I don't think that *version* control is the right model to describe what 
hg and git do, although it may be appropriate for subversion. hg doesn't 
manage *versions*, it manages changes to source code (changesets). 
Mercurial describes itself as a distributed source control management 
tool, so I think the term source control is quite appropriate.

http://mercurial.selenic.com/


-- 
Steve
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 'complex' function with string argument.

2014-03-18 Thread Steven D'Aprano
On Tue, 18 Mar 2014 08:04:44 +0100, Christian Gollwitzer wrote:

 Am 15.03.14 17:26, schrieb Jayanth Koushik:
 This is regarding the inbuilt 'complex' function. The python docs say:
 Note: When converting from a string, the string must not contain
 whitespace around the central + or - operator. For example,
 complex('1+2j') is fine, but complex('1 + 2j') raises ValueError.
 
 It's funny that you ask this question exactly now; because I'm currently
 implementing a compiler for a small language that understands complex
 numbers. As others have explained, the basic issue is the question how
 to parse an expression like
 
   1+2i*3
 
 is it complex(1+2i) times 3 

Putting my mathematician's hat on, I would say *absolutely not*.

 or is it sum of 1 and product of complex 2i and 3? 

This one. Multiplication has higher precedence than addition, so 1+2i*3 
has to be evaluated as 1+(2i*3).


-- 
Steve
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about Source Control

2014-03-18 Thread Chris Angelico
On Tue, Mar 18, 2014 at 6:55 PM, Steven D'Aprano st...@pearwood.info wrote:
 I don't think that *version* control is the right model to describe what
 hg and git do, although it may be appropriate for subversion. hg doesn't
 manage *versions*, it manages changes to source code (changesets).

Meh... Is there any real difference? With git, I can check out any
tree state I like (give me the 50th parent of the current HEAD), so
in that sense it effectively stores versions - at least, it can
retrieve or recreate versions. Does it store versions and optimize
them by recording only the difference, or record differences and
replay them to recreate a state? Two sides of the same coin.

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


Re: 'complex' function with string argument.

2014-03-18 Thread Christian Gollwitzer

Hi Steven,

Am 18.03.14 09:00, schrieb Steven D'Aprano:

On Tue, 18 Mar 2014 08:04:44 +0100, Christian Gollwitzer wrote:


Am 15.03.14 17:26, schrieb Jayanth Koushik:

This is regarding the inbuilt 'complex' function. The python docs say:
Note: When converting from a string, the string must not contain
whitespace around the central + or - operator. For example,
complex('1+2j') is fine, but complex('1 + 2j') raises ValueError.


It's funny that you ask this question exactly now; because I'm currently
implementing a compiler for a small language that understands complex
numbers. As others have explained, the basic issue is the question how
to parse an expression like

1+2i*3

is it complex(1+2i) times 3


Putting my mathematician's hat on, I would say *absolutely not*.


or is it sum of 1 and product of complex 2i and 3?


This one. Multiplication has higher precedence than addition, so 1+2i*3
has to be evaluated as 1+(2i*3).


The question was not whether the expression should be interpreted the 
first way, I'm sorry for being unclear. The question was how to 
implement this in a compiler. Because if you implement complex literals 
in the tokenizer, you would end up with the tokens of the first 
interpretation. But if you implement as imaginary literals, then your 
parse tree for 1+2i ends up as a sum of a real and an imaginary 
literal, instead of a complex literal. This works, but it lets your 
parse tree grow and possibly generates inefficient code. The answer I 
got here, is to parse it as a sum and let the optimizer combine it back 
into a single complex constant.



The same problem arises with unary minus, but it's less annoying because 
-(a*b) = (-a)*b.


I admit that my knowledge of compiler construction is limited, and I'm 
working on my first real-world application now. Oh, and it's not written 
in Python.


Christian


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


Re: Venus / GuthVenus for iPhone, Nexus, Droid and Android Jelly Bean

2014-03-18 Thread Chris Angelico
On Tue, Mar 18, 2014 at 2:45 PM, Brad Guth bradg...@yahoo.com wrote:
 You may want to revise that manifesto to read 'suffer and pay dearly'
 instead of GOING TO DIE, unless you meant via natural causes.

Don't bother responding to Thrinaxodon, it's a spammer.

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


Find and replace multiple RegEx search expressions

2014-03-18 Thread Jignesh Sutar
Hi,

I'm trying to delete contents of a .txt log file, matching on multiple
re.sub criteria but not sure how to achieve this.

Below is an illustration of what I am trying to achieve (of course in this
example I can combine the 3 re.sub into a single re expression but my
actual code will have a dozen plus expression I need to match on so easier
to keep them separate). Only the last re.sub will take effect in the
example below I need all 3 to take effect.


import re
o = open(rc:\temp\outputfile.txt,w)
data = open(rC:\Temp\infile.txt).read()
o.write( re.sub(.*X ,,data) )
o.write( re.sub(.*Y ,,data) )
o.write( re.sub(.*Z ,,data) )
o.close()


Thanks in advance.
Jignesh
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Find and replace multiple RegEx search expressions

2014-03-18 Thread Peter Otten
Jignesh Sutar wrote:

 Hi,
 
 I'm trying to delete contents of a .txt log file, matching on multiple
 re.sub criteria but not sure how to achieve this.
 
 Below is an illustration of what I am trying to achieve (of course in this
 example I can combine the 3 re.sub into a single re expression but my
 actual code will have a dozen plus expression I need to match on so easier
 to keep them separate). Only the last re.sub will take effect in the
 example below I need all 3 to take effect.
 
 
 import re
 o = open(rc:\temp\outputfile.txt,w)
 data = open(rC:\Temp\infile.txt).read()
 o.write( re.sub(.*X ,,data) )
 o.write( re.sub(.*Y ,,data) )
 o.write( re.sub(.*Z ,,data) )
 o.close()

Apply all substitutions to data before you write the result to the file:

with open(infile) as f:
data = f.read()

for expr in list_of_regexes:
data = re.sub(expr, , data)

with open(outfile, w) as f:
f.write(data)


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


Python3 html.parser

2014-03-18 Thread balaji marisetti
Hi,

I'm trying to parse a pice of HTML code using `html.parser` in Python3.
I want to find out the offset of a particular end tag (let's say /p) and
then stop processing
the remaining HTML code immediately. So I wrote something like this.

[code]
def handle_endtag(self, tag):
if tag == mytag:
#do something
self.reset()
[code]

I called `reset()` method at the end of  `handle_endtag()` method. Now the
problem is: when I call parser.feed(some html), it's giving an
AssertionError exception. Isn't the `reset()` method
supposed to be called inside handler methods?

Thanks,
Balaji
-- 
:-)balaji
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python3 html.parser

2014-03-18 Thread Peter Otten
balaji marisetti wrote:

 Hi,
 
 I'm trying to parse a pice of HTML code using `html.parser` in Python3.
 I want to find out the offset of a particular end tag (let's say /p) and
 then stop processing
 the remaining HTML code immediately. So I wrote something like this.
 
 [code]
 def handle_endtag(self, tag):
 if tag == mytag:
 #do something
 self.reset()
 [code]
 
 I called `reset()` method at the end of  `handle_endtag()` method. Now the
 problem is: when I call parser.feed(some html), it's giving an
 AssertionError exception. Isn't the `reset()` method
 supposed to be called inside handler methods?

Obviously not ;) After looking into the code I think there is no controlled 
way to stop parsing. I suggest that you raise a custom exception instead:

import html.parser

class TagFound(Exception):
pass

class MyParser(html.parser.HTMLParser):
def handle_endtag(self, tag):
if tag == wanted_tag:
raise TagFound

wanted_tag = a
parser = MyParser()
for data in [htmlbodya/a/body/html,
 htmlbodyb/b/body/html]:
try:
parser.feed(data)
except TagFound:
print(tag {!r} found.format(wanted_tag))
else:
print(tag {!r} not found.format(wanted_tag))
parser.reset()


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


Re: Question about Source Control

2014-03-18 Thread Steven D'Aprano
On Tue, 18 Mar 2014 19:08:17 +1100, Chris Angelico wrote:

 On Tue, Mar 18, 2014 at 6:55 PM, Steven D'Aprano st...@pearwood.info
 wrote:
 I don't think that *version* control is the right model to describe
 what hg and git do, although it may be appropriate for subversion. hg
 doesn't manage *versions*, it manages changes to source code
 (changesets).
 
 Meh... Is there any real difference? 

If you believe Joel Spolsky, there is:

http://hginit.com/00.html

Scroll down about half way, to the section titled One more big 
conceptual difference.

Recording *snapshots* versus recording *diffs* makes a considerable 
difference when it comes to dealing with merge conflicts.



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


Re: 'complex' function with string argument.

2014-03-18 Thread Marko Rauhamaa
Christian Gollwitzer aurio...@gmx.de:

 The same problem arises with unary minus, but it's less annoying
 because -(a*b) = (-a)*b.

   -1**2
  -1


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Unexpected comparisons in dict lookup

2014-03-18 Thread Steven D'Aprano
I stumbled across this unexpected behaviour with Python 2.7 and 3.3. When 
you look up a key in a dict, the key is sometimes compared against other 
keys twice instead of just once.

First, a class that reports when it is being tested for equality, with a 
fixed hash so that we get collisions inside the dict:

class Spam:
def __init__(self, label):
self.label = label
def __str__(self):
return self.label
def __hash__(self):
return 100
def __eq__(self, other):
print(comparing %s with %s % (self, other))
return self is other


Create a dict and prepare for collisions:

x = Spam(x)
y = Spam(y)
d = {100: 1}  # hash(100) == 100


When we add x to the dict, it collides with the existing key 100, so I 
expect one call to Spam.__eq__, and that's exactly what I get:

py d[x] = 200
comparing x with 100


But when I try adding y to the dict, it collides with 100, then it 
collides with x, then it apparently collides with x a second time:

py d[y] = 300
comparing y with 100
comparing x with y
comparing x with y


I expected only two calls to __eq__, not three: first comparing with 100, 
then comparing with x. Checking for keys gives the same result:

py x in d
comparing x with 100
True
py y in d
comparing y with 100
comparing x with y
comparing x with y
True


What's more, checking for a key which is not present also compares three 
times instead of twice:

py Spam(z) in d
comparing z with 100
comparing x with z
comparing x with z
comparing y with z
False


I expected it to compare z with 100, then x *once*, then y, then return 
False.

Why is the dict lookup comparing against x twice? It doesn't seem to be 
the fault of x. If I create a slightly different dict, with the 
collisions in a different order:

py e = {x: 100}
py e[100] = 200
comparing x with 100
py e[y] = 300
comparing x with y
comparing y with 100
comparing y with 100



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


Re: 'complex' function with string argument.

2014-03-18 Thread Mark H Harris

On 3/17/14 11:52 PM, Steven D'Aprano wrote:

On Mon, 17 Mar 2014 11:18:56 -0500, Mark H Harris wrote:

 Who knows, beats me.



With respect, that's just because you would make a lousy language
designer :-)


   Ouch;-)


How should one spell a complex number? There is perfectly good syntax
for complex numbers used by mathematicians and engineers for over a
century. There is no need to invent something different just for the sake
of being different:
 Yes:   2+3i or 2+3j


   Yes.  my Q was rhetorical only. And for the sake of discussion, 
particularly on the part of the OP, to think about what one expects 
based on experience and common sense, as a mathematician. (that doesn't 
mean it will be easy for the lexical parser.



Should we use i or j ? There are good reasons for both i and j. This
one comes down to personal preference.


   no, not really.  nobody writes,   e^(jPI) + 1 = 0

   Euler wants to see   e^(iPI) + 1 = 0  ;-)


Should the imaginary part be set off somehow? What do you mean set
off? Why do you want to? Since the imaginary part can appear on its own:


   simply, is 2j a literal complex part?  ...yes 2 j  ...no

   In other words, there must NEVER be a space between the 2 and j. 
This is debatable:   3 +2jalthough, I want to see3+2j




 z = 2 + 3j  # an expression adding 2 to 3j
 z = 5*3j  # an expression multiplying 5 by 3j


   all good, well until its not


How flexible should the complex constructor be? Should it bend over
backwards to accept any mathematical expression that includes a complex j
suffix, e.g. complex(2**3i)? I think not,


   I think not either.  But, it is possible to have *many* constructors/

   But, really, how often is this a problem?   like almost never!


complex( 3   +2j  )
(3+2j)
  
I don't know... you tell me.


In both cases, the call to complex is redundant. You've already created a
complex number, using syntax, then you pass it to the complex function
which just returns the same number.


   Of course.  I was merely pointing out that the constructor for 
'literals' (whatever you guys mean by that) is 'different' than the 
consistency with the string constructor.  As Chris pointed out these are 
two markedly different animals; one is a valid parse syntax, the other 
is a string constructor.   But here is my point--- to the user the 
difference comes down to semantics, which is not really true.


cf. below


complex('3+2j')
(3+2j)
complex('3 +2j')
Traceback (most recent call last):
File pyshell#17, line 1, inmodule
  complex('3 +2j')
ValueError: complex() arg is a malformed string




Also, philosophically, C ignores white space;  python does not.


   This was said tongue in cheek...  *both* languages inconsistently 
observer (and ignore) white space!  But, in general, white space is more 
important to python, and less important to C.


I'm still hung up on whether I'm a lousy language designer.  I guess 
we'll know if people use my language (or not)!  I suppose they might use 
it even though its lousy; on the other hand, it might be too simple for 
folks to be able to figure it out.   :)


marcus
--
https://mail.python.org/mailman/listinfo/python-list


Re: HOLY SH*T! HUMANS ORIGINATED IN THE DEVONIAN

2014-03-18 Thread Juha Nieminen
In comp.lang.c++ ASSODON troll@bitch.invalid wrote:
 THRINAXODON DANCED WITH JOY AS HE WAS GRANTED $600,000,000,000.000!

I find it interesting, from a psychological perspective, that you are
not even *pretending* that you are not lying and making stuff up.
You pretty much imply it as clearly as it possibly can be, and clearly
don't care. Yet, nevertheless, you accuse others of lying.

I don't think you are simply a troll who does this for his own amusement,
because even trolls get tired of the same old joke, and move to other
things. I get a feeling of this being more obsessive in nature.

There's something probably very wrong inside your head. I really think
you should seek professional help for your mental problems.

--- news://freenews.netfront.net/ - complaints: n...@netfront.net ---
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: HOLY SH*T! HUMANS ORIGINATED IN THE DEVONIAN

2014-03-18 Thread Danyelle Davis
Don't feed the trolls.  Actually talking to it makes it think you actually
care..


On Mon, Mar 17, 2014 at 4:50 AM, ASSODON troll@bitch.invalid wrote:

 ===
 BREAKING NEWS
 ===
 
 RICHARD LEAKEY JUST DIED DUE TO HEART FAILURE!
 
 THE REASONS DESCRIBED BY THE MEDICAL TEAM IS THAT HIS WORK WAS
 DISPROVEN, BY NONE OTHER THAN YOUR OWN BASTARD, THRINAXODON.
 
 THIS CAUSED LEAKEY'S HEART TO EXPLODE!
 
 THRINAXODON DANCED WITH JOY AS HE WAS GRANTED $600,000,000,000.000!
 
 TO WASTE YOUR TIME EVEN FURTHER, CHECK OUT THESE LINKS BELOW.
 ===
 EVIDENCE THAT HUMANS LIVED IN THE DEVONIAN:

 https://groups.google.com/group/sci.bio.paleontology/browse_thread/threa
 d/6f501c469c7af24f#


 https://groups.google.com/group/sci.bio.paleontology/browse_thread/threa
 d/3aad75c16afb0b82#


 

 http://thrinaxodon.wordpress.com/

 ===

 THRINAXODON ONLY HAD THIS TO SAY:

 I..I...I...Can't believe it. This completely disproved Darwinian
 orthodoxy.

 ===

 THE BASTARDS AT THE SMITHSONIAN, AND THE LEAKEY FOUNDATION ARE ERODING
 WITH FEAR.

 ===
 THESE ASSHOLES ARE GOING TO DIE:
 THOMAS AQUINAS;
 ALDOUS HUXLEY;
 BOB CASANVOVA;
 SkyEyes;
 DAVID IAIN GRIEG;
 MARK ISAAK;
 JOHN HARSHAM;
 RICHARD NORMAN;
 DR. DOOLITTLE;
 CHARLES DARWIN;
 MARK HORTON;
 ERIK SIMPSON;
 HYPATIAB7;
 PAUL J. GANS;
 JILLERY;
 WIKI TRIK;
 THRINAXODON;
 PETER NYIKOS;
 RON OKIMOTO;
 JOHN S. WILKINS
 ===

 THRINAXODON WAS SCOURING ANOTHER DEVONIAN FOSSIL BED, AND FOUND A
 HUMAN SKULL, AND A HUMAN FEMUR. HE ANALYSED THE FINDS, AND SAW THAT
 THEY WERE NOT NORMAL ROCKS. THESE WERE FOSSILIZED BONES. THEY EVEN HAD
 TOOTH MARKS ON THEM. SO, THRINAXODON BROUGHT THEM TO THE LEAKEY
 FOUNDATION, THEY UTTERLY DISMISSED IT, AND SAID, We want to keep
 people thinking that humans evolved 2 Ma. THRINAXODON BROUGHT HIS
 SWORD, AND SAID, SCIENCE CORRECTS ITSELF. RICHARD LEAKEY SAID, That
 is a myth, for people to believe in science. THRINAXODON PLANS TO
 BRING DOOM TO SCIENCE, ITSELF.

 

 THRINAXODON IS NOW ON REDDIT

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

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


extract stream title from the output of mplayer

2014-03-18 Thread Jabba Laci
Hi,

I have a simple command-line radio player and I want to extract song
titles from the output of mplayer.

Example:

$ mplayer http://relay2.slayradio.org:8000/

It produces a streamed output of this form:

MPlayer2 UNKNOWN (C) 2000-2012 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
...
ICY Info: StreamTitle='Alexander 'Taxim' Nev - Unsound minds feat.
SAM';StreamUrl='http://www.SLAYRadio.org/';
...

At the end it shows a progress indicator, thus the output is streamed.
The problem is I can't get this output in a string. My idea is to
launch mplayer with a timeout of 2 seconds for instance, get the
produced output and find the line that starts with ICY Info. But
when I kill the process after the timeout, I don't know how to fetch
the output produced so far.

Thanks,

Laszlo
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about Source Control

2014-03-18 Thread Mark H Harris

On 3/17/14 8:06 AM, Frank Millman wrote:

All my source code resides on an old Linux server, which I switch on in the
morning and switch off at night, but otherwise hardly ever look at. It uses
'samba' to allow sharing with Windows, and 'nfs' to allow sharing with other
Linux machines.


hi Frank, I am using GIT and code.google.com.

   https://code.google.com/p/pythondecimallibrary/

   I have not used Code Google prior to the pdeclib project; however, I 
plan to use it in the future extensively, at least for my open source 
projects (and when I am thinking about bringing another person on board.


   Code Google permits three version|control|access systems (I use GIT, 
a very simple command line interface).  The thing is that the code 
resides on a person's machine as a clone of the repository, and is 
assessable from anywhere in the world, allows multiple developer 
participation, allows multiple branches|merge|master, and allows access 
to the source on-line (browse|edit), and permits new members to clone 
the repository from anywhere.  Downloads are zipped.


   The down-side is also the up-side. Code Google is an open source 
developer collaborative environment for sharing  managing. Anything you 
put there belongs to everyone in the project, and can be viewed by 
anyone in the world (which is kinda the point of open source).  There is 
a supreme benefit to having multiple eyes on the code. People maybe not 
even involved in the project directly will comment on the code (and they 
are not shy). You code will improve dynamically and radically (if you 
have the guts for it).


   It took me a couple of hours to get up to speed with Code Google. It 
took another hour or so to come up to speed with GIT. You need to create 
the project on Code Google first. Then on your machine, in the code 
directory (the directory actually holding the source files that you are 
going to make a part of your project) you do these things:


   git init
   this builds the .git subdirectory needed for push

   git add file-name

   add each filename you want to commit and push

   git remove

   removes any unwanted files

   git commit -a

   edit your commit comments here ,  or provide default


   git push  https://code.google.com/p/whateveryourprojectnameis/ master

   sends the files on their way


   other files:.gitconfig.netrc


   You will place your name, email, and method (use simple) in the 
.gitconfig file.  The .netrc file will contain the login info for code 
google machine.



   Read the GIT manual on-line; its pretty easy too.

   https://www.kernel.org/pub/software/scm/git/docs/user-manual.html

   http://git-scm.com/documentation


Cheers



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


Re: extract stream title from the output of mplayer

2014-03-18 Thread Chris Angelico
On Wed, Mar 19, 2014 at 4:03 AM, Jabba Laci jabba.l...@gmail.com wrote:
 I have a simple command-line radio player and I want to extract song
 titles from the output of mplayer.

 ICY Info: StreamTitle='Alexander 'Taxim' Nev - Unsound minds feat.
 SAM';StreamUrl='http://www.SLAYRadio.org/';

 At the end it shows a progress indicator, thus the output is streamed.
 The problem is I can't get this output in a string. My idea is to
 launch mplayer with a timeout of 2 seconds for instance, get the
 produced output and find the line that starts with ICY Info. But
 when I kill the process after the timeout, I don't know how to fetch
 the output produced so far.

My first recommendation would be to see what you can get directly,
rather than calling on mplayer. But otherwise, what you want to do is
redirect the output somewhere. Are you using the Python subprocess
module to do this? You haven't shown any code, but since you posted
this to python-list I'm guessing that you probably are talking about
Python. (Or s/guess/hop/ if you prefer!) There are many ways this
could be done; what have you tried, what partly worked, what did
something unexpected?

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


Re: extract stream title from the output of mplayer

2014-03-18 Thread Jabba Laci
 Python. (Or s/guess/hop/ if you prefer!) There are many ways this
 could be done; what have you tried, what partly worked, what did
 something unexpected?

Hi,

I managed to solve the problem. In the man of mplayer I found how to
quit after X seconds: -endpos X. See my solution below.

Best,

Laszlo



import re
import shlex
from subprocess import PIPE, Popen

URL = 'http://relay2.slayradio.org:8000/'


def get_exitcode_stdout_stderr(cmd):

Execute the external command and get its exitcode, stdout and stderr.

args = shlex.split(cmd)

proc = Popen(args, stdout=PIPE, stderr=PIPE)
out, err = proc.communicate()
exitcode = proc.returncode
#
return exitcode, out, err


def get_title():
cmd = mplayer -endpos 1 -ao null {url}.format(url=URL)
out = get_exitcode_stdout_stderr(cmd)[1]

for line in out.split(\n):
#print(line)
if line.startswith('ICY Info:'):
match = re.search(rStreamTitle='(.*)';StreamUrl=, line)
title = match.group(1)
return title

def main():
print(get_title())
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Balanced trees

2014-03-18 Thread Dan Stromberg
On Mon, Mar 17, 2014 at 3:05 PM, Marko Rauhamaa ma...@pacujo.net wrote:
 Joshua Landau jos...@landau.ws:

 The thing we really need is for the blist containers to become stdlib
 (but not to replace the current list implementation).

 Very interesting. Downloaded blist but didn't compile it yet. It *could*
 be the missing link.

 I would *love* to see some comparative performance results between
 blist.sorteddict and an AVL tree.

I added blist.sorteddict and removed (temporarily) Pypy and Jython.
The results are at
http://stromberg.dnsalias.org/~strombrg/python-tree-and-heap-comparison/2014-03/

In short, blist.sorteddict didn't do that well, despite being in C.
In the random workloads, blist.sorteddict was dead last.  In the
sequential workloads blist.sorteddict fell somewhere in the middle.

I excluded Pypy and Jython because blist.sorteddict probably doesn't
run on them.

HTH
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Unexpected comparisons in dict lookup

2014-03-18 Thread Ian Kelly
On Tue, Mar 18, 2014 at 8:20 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 I stumbled across this unexpected behaviour with Python 2.7 and 3.3. When
 you look up a key in a dict, the key is sometimes compared against other
 keys twice instead of just once.

From what I can see in the code, it adds a perturbation based on the
upper bits of the hash value to the probing scheme, to reduce
collisions for keys with unequal hashes.  On the downside, this
cancels the guarantee that each bucket can only be checked at most
once.  The perturbation gradually shifts to 0 after a few iterations,
so every bucket can still be reached within O(n) iterations.

See the comments starting at Major subtleties ahead:
http://hg.python.org/cpython/file/f8b40d33e45d/Objects/dictobject.c#l106
-- 
https://mail.python.org/mailman/listinfo/python-list


Controlling buffer alignment in file.read()

2014-03-18 Thread Haralanov, Mitko
Hi all,

I am using Python to read from a binary device file which requires that all 
read sizes are in 8byte multiples and the user's buffer is 8byte aligned.

I am currently using a file object and the file.read() method. However, the 
issue is that the file.read() method allocates the buffer passed to C function 
under the covers and, therefore, the alignment is arbitrary.

Is there a way that I can get file.read() to use an 8byte aligned buffer?

Thanks,
- Mitko


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


Re: Question about Source Control

2014-03-18 Thread Dave Angel
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info Wrote in
 message:
 On Tue, 18 Mar 2014 19:08:17 +1100, Chris Angelico wrote:
 
 On Tue, Mar 18, 2014 at 6:55 PM, Steven D'Aprano st...@pearwood.info
 wrote:
 I don't think that *version* control is the right model to describe
 what hg and git do, although it may be appropriate for subversion. hg
 doesn't manage *versions*, it manages changes to source code
 (changesets).
 
 Meh... Is there any real difference? 
 
 If you believe Joel Spolsky, there is:
 
 http://hginit.com/00.html
 
 Scroll down about half way, to the section titled One more big 
 conceptual difference.
 
 Recording *snapshots* versus recording *diffs* makes a considerable 
 difference when it comes to dealing with merge conflicts.
 

So which does git do, according to this model? 


-- 
DaveA

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


Re: Balanced trees

2014-03-18 Thread Marko Rauhamaa
Dan Stromberg drsali...@gmail.com:

 The results are at
 http://stromberg.dnsalias.org/~strombrg/python-tree-and-heap-comparison/2014-03/

Unfortunately I'm having a hard time understanding the results.

The 50/50 get/set ratio is most interesting to me.

I'm seeing (under cpython-3.3):


Size: 1048576, duration:  75.3, dictionary type: dict
[...]
Size:  262144, duration:  66.1, dictionary type: AVL_tree
[...]
Size:   65536, duration:  77.3, dictionary type: blist.sorteddict 


What does it mean?


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


mobile friendly docs?

2014-03-18 Thread klo uo
Hi,

let me quickly introduce my concern - I was happy to see main
python.org portal rendered nicely on mobile, but docs are still hardly
accessible, while sphinx allows better experience if user instructs it
to.

So I browsed Python MLs (sorry if this is not the right one, I'd be
happy to forward my mail where you suggest) and wanted to ask if such
concern is planed, as I can run Python from years ago on my Nokias,
while feeling strange that official docs aren't accessible from
mobile.


TIA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Balanced trees

2014-03-18 Thread Dan Stromberg
On Tue, Mar 18, 2014 at 1:55 PM, Marko Rauhamaa ma...@pacujo.net wrote:
 Dan Stromberg drsali...@gmail.com:

 The results are at
 http://stromberg.dnsalias.org/~strombrg/python-tree-and-heap-comparison/2014-03/

 Unfortunately I'm having a hard time understanding the results.

 The 50/50 get/set ratio is most interesting to me.

 I'm seeing (under cpython-3.3):


 Size: 1048576, duration:  75.3, dictionary type: dict
 [...]
 Size:  262144, duration:  66.1, dictionary type: AVL_tree
 [...]
 Size:   65536, duration:  77.3, dictionary type: blist.sorteddict


 What does it mean?

dict was able to do 1048576 operations on a dictionary before taking
more than 120 seconds to complete - it took 75.3 seconds to do 1048576
operations.

AVL_tree was able to do 262144 operations on a dictionary before
taking more than 120 seconds to complete - it took 66.1 seconds to do
262144 operations.

blist.sorteddict was able to do 65536 operations on a dictionary
before taking more than 120 seconds to complete  - it took 77.3
seconds to do 65536 operations.

For the 50/50 workload; the operations were half adding key, value
pairs; and half lookups of values by keys we know are in the
dictionary.

I used to run all the dictionaries for as long as it took to do 4
million operations, but for (EG) unbalanced binary trees, that would
take far too long in the ordered tests, so I changed the code to try a
given tree type until the time for an operation became prohibitive.

If you look at the graphs (I have to admit they've become a little
cluttered), you can see the slower trees escaping rapidly (exceeding
the 120 second threshold), while the better performing trees grow more
slowly and are allowed to continue proving themselves longer.
Inspecting these graphs may help in developing an intuition for how
the tests were conducted.

The code implementing this method of testing is in
http://stromberg.dnsalias.org/svn/python-tree-and-heap-comparison/trunk/tester

HTH
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about Source Control

2014-03-18 Thread Gregory Ewing

Frank Millman wrote:
These are the kind of stumbling blocks that prevented me from succeeding in 
my previous attempt. I have a vague recollection that I set it up on machine 
A, but then hit a problem because machines B and C both accessed the same 
directory, but with different names


For dealing with your practice of editing on one machine and
running on another, you may be best off having just *one* local
repository, residing on the shared file system. Whichever machine
you're working on, you cd to the shared directory and use hg or
git commands from there, so all the pathnames you're using are
relative.

Source control operations might be slightly slower that way,
but you'd save time by not having to update your local repo
every time you switch between editing and running, so it may
well be faster overall. In any case, if the machines involved
are on a fast local network, I wouldn't expect there to be
much difference.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: Balanced trees

2014-03-18 Thread Marko Rauhamaa
Dan Stromberg drsali...@gmail.com:

 dict was able to do 1048576 operations on a dictionary before taking
 more than 120 seconds to complete - it took 75.3 seconds to do 1048576
 operations.

 AVL_tree was able to do 262144 operations on a dictionary before
 taking more than 120 seconds to complete - it took 66.1 seconds to do
 262144 operations.

 blist.sorteddict was able to do 65536 operations on a dictionary
 before taking more than 120 seconds to complete - it took 77.3 seconds
 to do 65536 operations.

For a proper comparison, I'd like a fixed, identical dataset and set of
operations run against each data structure.

How about this test program:

   generate random datasets of 100, 1, 100 and 1 elements
   generate random testset of 100 elements
   for each data structure:
for each dataset:
 initialize data structure with dataset
 head, tail = testset[:100], testset[100:]
 t0 = current timestamp
 for each element in head:
  add element to data structure
 for each element in tail:
  add element to data structure
  append element to head
  remove head.pop(0) from data structure
 for each element in head:
  remove element from data structure
 t1 = current timestamp
 report data structure type, dataset size, t1 - t0


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Balanced trees

2014-03-18 Thread Dan Stromberg
On Tue, Mar 18, 2014 at 3:03 PM, Marko Rauhamaa ma...@pacujo.net wrote:
 Dan Stromberg drsali...@gmail.com:
 For a proper comparison, I'd like a fixed, identical dataset and set of
 operations run against each data structure.

 How about this test program:

I used to do essentially this, but it was time-prohibitive and
produced harder-to-read graphs - harder to read because the enormous
values of the bad trees were dwarfing the values of the good trees.

Imagine doing 1 operation tests for the unbalanced binary
tree. For a series of random keys, it would do quite well (probably
second only to dict), but for a series of sequential keys it would
take longer than anyone would reasonably want to wait because it's
basically a storage-inefficient linked list.

Rather than throw out unbalanced binary tree altogether, it makes more
sense to run it until it gets too slow.

The workload+interpreter pairs are all tested the same way, it's just
that the ones that are doing badly are thrown out before they're able
to get a lot worse. Studying the graphs will likely help develop an
intuition for what's happening.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Controlling buffer alignment in file.read()

2014-03-18 Thread Gregory Ewing

Haralanov, Mitko wrote:

I am using Python to read from a binary device file which requires that all
read sizes are in 8byte multiples and the user's buffer is 8byte aligned.

Is there a way that I can get file.read() to use an 8byte aligned buffer?


For control at that level you'd be better off using
direct system calls, i.e. os.open() and os.read(),
then you can read exacty the number of bytes you want.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


RE: Controlling buffer alignment in file.read()

2014-03-18 Thread Haralanov, Mitko
 For control at that level you'd be better off using
 direct system calls, i.e. os.open() and os.read(),
 then you can read exacty the number of bytes you want.
 

The problem is not controlling the number of bytes read. That part seems to be 
working.
The issue is that the buffer into which the data is placed needs to be of 
certain alignment (8byte-aligned). Python does not seem to have a way that 
allows me to control that.

Thanks,
- Mitko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Balanced trees

2014-03-18 Thread Marko Rauhamaa
Dan Stromberg drsali...@gmail.com:

 On Tue, Mar 18, 2014 at 3:03 PM, Marko Rauhamaa ma...@pacujo.net wrote:
 Dan Stromberg drsali...@gmail.com:
 For a proper comparison, I'd like a fixed, identical dataset and set
 of operations run against each data structure.

 How about this test program:

 I used to do essentially this, but it was time-prohibitive and
 produced harder-to-read graphs - harder to read because the enormous
 values of the bad trees were dwarfing the values of the good trees.

 Imagine doing 1 operation tests for the unbalanced binary
 tree. For a series of random keys, it would do quite well (probably
 second only to dict), but for a series of sequential keys it would
 take longer than anyone would reasonably want to wait because it's
 basically a storage-inefficient linked list.

 Rather than throw out unbalanced binary tree altogether, it makes more
 sense to run it until it gets too slow.

I disagree strongly. You should throw out unbalanced binary trees and
linked lists and the like and concentrate on solid contenders.

But it's your test. You do as you like.

Anyway, even a well-thought-out test is subject to all kinds of
criticisms due to the CPU architecture, the distribution of the key
values, the quality of the data structure implementation etc etc.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Controlling buffer alignment in file.read()

2014-03-18 Thread Gregory Ewing

Haralanov, Mitko wrote:


The problem is not controlling the number of bytes read. That part seems to
be working. The issue is that the buffer into which the data is placed needs
to be of certain alignment (8byte-aligned). Python does not seem to have a
way that allows me to control that.


Hmmm, that could be tricky. Have you tried using os.read()?
If you're lucky, Python will be using a malloc() call or
equivalent to create a str/bytes object to read the data
into, and that will return something platform-aligned.

If you're unlucky, there's probably no pure-Python
solution, and you might need to write a small C or
Cython module to accomplish this trick.


--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: Controlling buffer alignment in file.read()

2014-03-18 Thread Dan Stromberg
On Tue, Mar 18, 2014 at 1:23 PM, Haralanov, Mitko
mitko.harala...@intel.com wrote:
 Hi all,

 I am using Python to read from a binary device file which requires that all 
 read sizes are in 8byte multiples and the user's buffer is 8byte aligned.

 I am currently using a file object and the file.read() method. However, the 
 issue is that the file.read() method allocates the buffer passed to C 
 function under the covers and, therefore, the alignment is arbitrary.

 Is there a way that I can get file.read() to use an 8byte aligned buffer?

This is a lot like what my odirect project does:
http://stromberg.dnsalias.org/~strombrg/odirect/

It does buffer alignment, because O_DIRECT requires buffer alignment.
It's a Python-callable SWIG wrapper for some C code.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Balanced trees

2014-03-18 Thread Chris Kaynor

 On Tue, Mar 18, 2014 at 1:55 PM, Marko Rauhamaa ma...@pacujo.net wrote:

Dan Stromberg drsali...@gmail.com:
  The results are at
 
 http://stromberg.dnsalias.org/~strombrg/python-tree-and-heap-comparison/2014-03/



  Size: 1048576, duration:  75.3, dictionary type: dict
 [...]
 Size:  262144, duration:  66.1, dictionary type: AVL_tree
 [...]
 Size:   65536, duration:  77.3, dictionary type: blist.sorteddict


Taking a quick look at this, I think it might be made much clearer if the
number/second were added to the output. While it can be computed off the
displayed data, it would make it much easier to compare in the table view
by including it. Something like:

  Size: 1048576, duration:  75.3, dictionary type: 13925/second: dict
  Size:  262144, duration:  66.1, dictionary type: 3965/second: AVL_tree
  Size:   65536, duration:  77.3, dictionary type: 847/second:
blist.sorteddict

Chris
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Balanced trees

2014-03-18 Thread Steven D'Aprano
On Wed, 19 Mar 2014 01:11:33 +0200, Marko Rauhamaa wrote:

 Dan Stromberg drsali...@gmail.com:

 Rather than throw out unbalanced binary tree altogether, it makes more
 sense to run it until it gets too slow.
 
 I disagree strongly. You should throw out unbalanced binary trees and
 linked lists and the like and concentrate on solid contenders.

If you are in a position to randomize the data before storing it in the 
tree, an unbalanced binary tree is a solid contender. The overhead will 
likely be much less than any balanced tree, and the probability of 
degenerate behaviour negligible for any amount of data big enough to 
really matter.



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


Re: Balanced trees

2014-03-18 Thread Steven D'Aprano
On Tue, 18 Mar 2014 15:21:28 -0700, Dan Stromberg wrote:

 On Tue, Mar 18, 2014 at 3:03 PM, Marko Rauhamaa ma...@pacujo.net
 wrote:
 Dan Stromberg drsali...@gmail.com:
 For a proper comparison, I'd like a fixed, identical dataset and set of
 operations run against each data structure.

 How about this test program:
 
 I used to do essentially this, but it was time-prohibitive and produced
 harder-to-read graphs - harder to read because the enormous values of
 the bad trees were dwarfing the values of the good trees.

A log graph may be the solution to that: graph the log of the time rather 
than time itself.



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


Re: Question about Source Control

2014-03-18 Thread Terry Reedy

On 3/18/2014 5:51 PM, Gregory Ewing wrote:

Frank Millman wrote:

These are the kind of stumbling blocks that prevented me from
succeeding in my previous attempt. I have a vague recollection that I
set it up on machine A, but then hit a problem because machines B and
C both accessed the same directory, but with different names


For dealing with your practice of editing on one machine and
running on another, you may be best off having just *one* local
repository, residing on the shared file system. Whichever machine
you're working on, you cd to the shared directory and use hg or
git commands from there, so all the pathnames you're using are
relative.


At least with hg, one should best test the code in the working directory 
*before* committing to the local repository. The one local repository 
could still be a close of a master repository somewhere else. One can 
push multiple commits at once, either as the end of a work session or 
when one has done enough to become paranoid about losing work.




--
Terry Jan Reedy

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


[no subject]

2014-03-18 Thread Nathan Bruce
Hi I was wondering how much your oxycontins are for what mg and quantity.
Also do you guys sell dilaudid?

Thank you
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about Source Control

2014-03-18 Thread Tim Chase
On 2014-03-18 21:38, Terry Reedy wrote:
 At least with hg, one should best test the code in the working
 directory *before* committing to the local repository. 

I don't know if this is a hg-vs-git way of thinking, but I tend to
frequently commit things on a private development branch regardless
of brokenness, but once I get it working, I flatten  clean up those
changes (rebase in git terms, which I believe has been adopted as a
standardly-available-but-not-enabled-by-default module in hg) into
logical units of change-sets that I then test individually before
applying them to my more public-facing branch.  This produces clean
history that makes it easy for others to see what's going on.

-tkc



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


Re: Question about Source Control

2014-03-18 Thread Chris Angelico
On Wed, Mar 19, 2014 at 1:12 PM, Tim Chase
python.l...@tim.thechases.com wrote:
 On 2014-03-18 21:38, Terry Reedy wrote:
 At least with hg, one should best test the code in the working
 directory *before* committing to the local repository.

 I don't know if this is a hg-vs-git way of thinking, but I tend to
 frequently commit things on a private development branch regardless
 of brokenness, but once I get it working, I flatten  clean up those
 changes (rebase in git terms, which I believe has been adopted as a
 standardly-available-but-not-enabled-by-default module in hg) into
 logical units of change-sets that I then test individually before
 applying them to my more public-facing branch.  This produces clean
 history that makes it easy for others to see what's going on.

My approach to rebasing is derived from the accountancy concepts my
Dad taught me. You create transactions, invoices, whatever, and you
can freely edit them so long as they're the current batch. It's very
clear what the current batch is and where history begins. Then when
you update that batch, it becomes history and is indelible; if you
find an error in history, you put a new transaction through that
updates it (or maybe reverses it completely, so you can then do a new
clean transaction), which will have its own date (the date of the
correction) and its own identity. [1] In git terms, that means commits
above origin/master are freely editable, but as soon as anything's
pushed, it's not to be changed. I violate that rule only very VERY
occasionally, and only with the understanding that every clone of the
repo will have to be manually updated.

The git rebase -i command is perfect for this - it lets you rewrite
anything that isn't pushed yet, by default. I made myself a hook
script that helps with this; between that and the autosquash feature
of git rebase interactive, it's easy to fiddle with unpushed changes.
Let's say you discover a typo in an unpushed commit, and go and fix
the corresponding file. As long as it's a one-file edit, and the most
recent edit to that file is the commit you want to fix up, just type:

$ git commit -amf

or

$ git commit some-file -mf

and it'll make a fixup commit marked with that commit's message. Then:

$ git rebase -i

will notice that (if autosquash is enabled) and offer to squash the
two commits together. In all cases, only unpushed commits are
considered; everything from origin/master is untouchable.

If anyone wants the script, I'm happy to share, though it is
git-specific. Porting it to hg (does hg do hooks? I'm sure it must) is
left as an exercise for the reader :)

ChrisA

[1] Linking this in with a previous thread on identity vs value: a
transaction definitely has an identity, which may or may not be
representable with some sort of database ID field. The identity might
be something like third row of the current batch and nothing more,
but it has one.
-- 
https://mail.python.org/mailman/listinfo/python-list


Greetings from Al-Madinah International University

2014-03-18 Thread marwa kotb
Al Salam Alaykom w rahmat allah w barkato

 
Dear : mr \  mrs
We are pleased that on behalf of the Al-Madinah International University 
[MEDIU] greetings and best wishes for you continued success , coupled with the 
sincere invitations for your further success and development and growth.
 
 
Al-Madinah International University [MEDIU] Malaysia: University City World 
[MEDIU] Malaysia is one of the leading universities of Malaysia, which is 
characterized by excellence and excellence of technical and higher education 
areas, and  Al-Madinah International University [MEDIU]  is a multiple 
cultures and areas of study and is based
Malaysia  Shah Alam , Here is a brief history.
1.  Al-Madinah International University [MEDIU] founded early in 2004 in 
Medinah  Almonowra 
 
2. In 19 / July / 2006, the university received the invitation of the Malaysian 
Ministry of Higher Education for the establishment of the University Centre in 
Malaysia.
 
3. On 20 / July / 2007, the university obtained full license from the Ministry 
of Higher Education Malaysia to be the first international  Malaysian 
University pursuing a systematic distance education using e-learning Targeting 
the  Students from around the world.
 
4. In early of February of 2008 the university began full operation of 
reception of students. 
5. joined the university for beginning of the year 2009, approximately [1500 ] 
students from different countries, while the number of applications submitted 
to the University of [3000] enrollment request.
 
. 6. Early / 2009. University offered more than (24) academic program 
accredited by the Accreditation Authority and the Ministry of Higher Education 
(Malaysia), and more (34) accredited course in Arabic and English language 
center.
 
. 7. Early 2009. Varied the levels of academic programs at the university to 
include foundation studies ,  Pre-university, diploma, bachelor's degree - 
graduate studies, language training courses.
8. Mid-2009. The number of students who were enrolled in the university more 
than (4701) students from more than 40 nationalities around the world.
 
. 9. The third quarter of 2009. The Al-Madinah International University [MEDIU] 
Passed successfully institutional inspection held by the Malaysian Ministry of 
Higher Education to ensure quality of academic and administrative of the 
University.
 
10 . The end of 2009. The number of applications increased by the University of 
(6508) Application from more than (60) countries around the world, while the 
number of students enrolled in the University (2482 )
 
11. The end of 2009.The university Completed the (10) new programs of study for 
approval by the  Malaysian accreditation of Graduate Studies.
 
12. The end of 2009. The Al-Madinah International University [MEDIU] started 
the procedures to start the constituent university education in the disciplines 
of direct scientific and practical, including a new Computer Science, Finance 
and Administration, Engineering and intending to be started by mid-year 2010.
 
13. . Early in 2010. The number of students of the University increased to 
(3057) students from around the world, from the beginning of September  2010.
 
14. The end of 2010. The number of applications received the university for 
direct education on campus system around (511) applications and more than (154) 
enrollment students.
 
15. Early of  2011. The number of applications received by the 
university to direct education on campus system (2312) The number of enrollment 
students  more than (362).
. . 16. Early in 2011. Al-Madinah International University [MEDIU] inclusion 
Programs of the  Al-Madinah International University [MEDIU] in full 
accreditation for four academic graduate programs in the Faculty of Islamic 
Sciences in the list of qualifications recognized by the Civil Service 
Commission, Malaysia
 
17. The end of 2011. The university  the graduating first graduating batch of 
students from the  Al-Medina International University  in the  master's 
programs, bachelor's and (84) students for the bachelor's degree, and (27) 
students for master's degree.
 
 
What distinguishes the Al-Medinah International University [MEDIU].
 
First, high-technical  and modern facilities: The technical infrastructure of 
the Al-Medinah International University  is designed to match the best 
standards in the field of modern e-learning and distance education, including 
those of infrastructure following matters: 
 
Al-Medinah International University website on the Internet www.mediu.edu.my: 
which offers all university services, which content  admission, registration , 
inquiry , direct access to the lessons and communicate with lecturers  and 
administrators staff of t the university.
 
The electronic system of educational administration Alim for managing  the  
academic affairs of  the university, which can be both a student university 
lectures , administrators and supervisors to manage all the  Process of 

[issue19640] Drop _source attribute of namedtuple

2014-03-18 Thread Eric Snow

Eric Snow added the comment:

It does not necessarily require a metaclass.  You can accomplish it using a 
custom descriptor:

class classattr:
def __init__(self, getter):
self.getter = getter
def __get__(self, obj, cls):
return self.getter(cls)

FWIW, this is a descriptor that may be worth adding somewhere regardless.

--

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



[issue20954] Bug in subprocess._args_from_interpreter_flags causes MemoryError

2014-03-18 Thread Marc Schlaich

Changes by Marc Schlaich marc.schla...@googlemail.com:


--
nosy: +ncoghlan

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



[issue20954] Bug in subprocess._args_from_interpreter_flags causes MemoryError

2014-03-18 Thread Marc Schlaich

Marc Schlaich added the comment:

This was fixed in #19284 for Python 3.4 (without having possible consequences 
in mind). I have updated my patch accordingly.

Maybe it's worth to port my test case to Python 3.4.

Removed Python 3.3 as it isn't in bugfix maintenance anymore.

--
versions:  -Python 3.3
Added file: http://bugs.python.org/file34480/Issue20954.patch

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



[issue20112] The documentation for http.server error_message_format is inadequate.

2014-03-18 Thread Anastasia.Filatova

Changes by Anastasia.Filatova anastasia.n.filat...@gmail.com:


Removed file: http://bugs.python.org/file34467/Issue20112_py27.patch

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



[issue20112] The documentation for http.server error_message_format is inadequate.

2014-03-18 Thread Anastasia.Filatova

Changes by Anastasia.Filatova anastasia.n.filat...@gmail.com:


Removed file: http://bugs.python.org/file34469/Issue20112_py34.patch

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



[issue20112] The documentation for http.server error_message_format is inadequate.

2014-03-18 Thread Anastasia.Filatova

Changes by Anastasia.Filatova anastasia.n.filat...@gmail.com:


Removed file: http://bugs.python.org/file34468/Issue20112_py33.patch

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



[issue20112] The documentation for http.server error_message_format is inadequate.

2014-03-18 Thread Anastasia.Filatova

Changes by Anastasia.Filatova anastasia.n.filat...@gmail.com:


Added file: http://bugs.python.org/file34481/Issue20112_py34.patch

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



[issue20112] The documentation for http.server error_message_format is inadequate.

2014-03-18 Thread Anastasia.Filatova

Changes by Anastasia.Filatova anastasia.n.filat...@gmail.com:


Added file: http://bugs.python.org/file34482/Issue20112_py33.patch

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



[issue20112] The documentation for http.server error_message_format is inadequate.

2014-03-18 Thread Anastasia.Filatova

Anastasia.Filatova added the comment:

Thank you, Eric for your comments! I see now what doese the 'review' link mean 
:)   You are right the send_error should be a method not a class variable. I 
changed it in a new patch. As regards the responses I prefer don't change it to 
a class attribute because in documentation it is mentioned as a class variable 
in several places. I also checked that :attr:`send_error` does generate a link 
to send_error method in html.

--

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



[issue20112] The documentation for http.server error_message_format is inadequate.

2014-03-18 Thread Anastasia.Filatova

Changes by Anastasia.Filatova anastasia.n.filat...@gmail.com:


Added file: http://bugs.python.org/file34483/Issue20112_py27.patch

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



[issue17110] sys.argv docs should explaining how to handle encoding issues

2014-03-18 Thread andy.ma

Changes by andy.ma andy.ju...@gmail.com:


--
nosy: +andyma

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



[issue19640] Drop _source attribute of namedtuple (waste memory)

2014-03-18 Thread STINNER Victor

STINNER Victor added the comment:

namedtuple_source.patch: Replace _source attribute wasting memory with a 
property generating the source on demand. The patch adds also unit test for the 
verbose attribute (which is public and documented, even it is said to be 
outdated).

The patch removes also repr_fmt and num_fields parameters of the class 
definition template, compute these values using the list of fields.

I suggested to change Python 3.4.1 and 3.5.

Test script:
---
import email
import http.client
import pickle
import test.regrtest
import test.test_os
import tracemalloc
import xmlrpc.server

snap = tracemalloc.take_snapshot()
with open(dump.pickle, wb) as fp:
pickle.dump(snap, fp, 2)
---

With the patch, the memory footprint is reduced by 176 kB.

--
keywords: +patch
title: Drop _source attribute of namedtuple - Drop _source attribute of 
namedtuple (waste memory)
type:  - resource usage
versions: +Python 3.5
Added file: http://bugs.python.org/file34484/namedtuple_source.patch

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



[issue20966] Documentation Link for Python Tkinter Resources is currently broken

2014-03-18 Thread andy.ma

New submission from andy.ma:

The Python Tkinter Resources link(http://www.python.org/topics/tkinter/) 
resides in the topic of tkinter — Python interface to 
Tcl/Tk(http://docs.python.org/2/library/tkinter.html) is currently broken.

It redirects to https://www.python.org/topics/tkinter/; which presented a 404 
error.

--
assignee: docs@python
components: Documentation
messages: 213950
nosy: andyma, docs@python
priority: normal
severity: normal
status: open
title: Documentation Link for Python Tkinter Resources is currently broken
type: resource usage
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5

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



[issue8813] SSLContext doesn't support loading a CRL

2014-03-18 Thread Christian Heimes

Christian Heimes added the comment:

Yes, Python 3.4 can load and use CRLs.

--
status: open - closed

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



[issue8813] SSLContext doesn't support loading a CRL

2014-03-18 Thread STINNER Victor

STINNER Victor added the comment:

 Yes, Python 3.4 can load and use CRLs.

Great work Christian, I was expecting this feature since many years :-)

--

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



[issue8813] SSLContext doesn't support loading a CRL

2014-03-18 Thread Christian Heimes

Christian Heimes added the comment:

It was *really* trivial. I just had to expose two simple OpenSSL APIs to enable 
/ disable CRL. All versions of Python could already load the CRLs but CRL 
checks could not be enabled.

--

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



[issue8813] SSLContext doesn't support loading a CRL

2014-03-18 Thread STINNER Victor

STINNER Victor added the comment:

 It was *really* trivial. I just had to expose two simple OpenSSL APIs to 
 enable / disable CRL.

It was trivial thanks to all the work done before around SSLContext. For 
example, Python 2.7 doesn't have SSLContext, so adding support for CRL in 
Python 2.7 is non-trivial :-/

--

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



[issue11416] netrc module does not handle multiple entries for a single host

2014-03-18 Thread Berker Peksag

Berker Peksag added the comment:

I've updated the tests to match the changes in issue 12009 and documentation a 
bit.

--
nosy: +berker.peksag
versions: +Python 3.5 -Python 3.3
Added file: http://bugs.python.org/file34485/issue11416.diff

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



[issue17462] argparse FAQ: how it is different from optparse

2014-03-18 Thread Anastasia.Filatova

Anastasia.Filatova added the comment:

Now argparse documentation includes a paragraph about advantages of argparse 
module over optparse module.

--
keywords: +patch
nosy: +Anastasia.Filatova
Added file: http://bugs.python.org/file34486/Issue17462_py27.patch

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



[issue17462] argparse FAQ: how it is different from optparse

2014-03-18 Thread Anastasia.Filatova

Changes by Anastasia.Filatova anastasia.n.filat...@gmail.com:


Added file: http://bugs.python.org/file34487/Issue17462_py33.patch

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



[issue17462] argparse FAQ: how it is different from optparse

2014-03-18 Thread Anastasia.Filatova

Changes by Anastasia.Filatova anastasia.n.filat...@gmail.com:


Added file: http://bugs.python.org/file34488/Issue17462_py34.patch

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



[issue20827] IDLE : Display function argument list in ClassBrowser

2014-03-18 Thread Saimadhav Heblikar

Changes by Saimadhav Heblikar saimadhavhebli...@gmail.com:


Removed file: 
http://bugs.python.org/file34439/classbrowser-improvements-v2.patch

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



[issue17462] argparse FAQ: how it is different from optparse

2014-03-18 Thread Éric Araujo

Éric Araujo added the comment:

Thanks for the patch, will apply.

--
assignee: docs@python - eric.araujo
stage: needs patch - commit review

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



[issue20897] @abstractmethod does not enforce method signatures

2014-03-18 Thread the mulhern

the mulhern added the comment:

I feel that I worded this in a way that makes it look like I'm asking for an 
enhancement, not reporting a bug, so I'll try again.

The documentation for 2.7.6 and 3.4.0 says:

Using this decorator requires that the class’s metaclass is ABCMeta or is 
derived from it. A class that has a metaclass derived from ABCMeta cannot be 
instantiated unless all of its abstract methods and properties are overridden. 
The abstract methods can be called using any of the normal ‘super’ call 
mechanisms.

The second sentence is a little obscure, but what it must mean is that a class 
that has a metaclass derived from ABCMeta or a class that extends such a class 
cannot be instantiated unless all of its abstract method and properties are 
overridden.

Now, in this example, both Sub and SuperSubber have an abstract method 
_junk(self) and neither of them overrides this method. Therefore, neither 
should be instantiated.

But they can both be instantiated in 3.3 and one can be instantiated in 2.7.

So, the behavior does seem to me to disagree with the documentation.

In fact, in Python 3.3.2 I can instantiate the META class in the example, which 
seems really wrong. I can not instantiate the META class in 2.7.6.

--
type: enhancement - behavior

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



[issue20918] Logging of logging exceptions can fail in 3.4 if args are unprintable

2014-03-18 Thread the mulhern

the mulhern added the comment:

Thanks for the fix.

When you say having repr raise is a pretty unusual occurrence you probably 
mean having repr raise should be a pretty unusual occurrence.

I think its more usual than you realize and the regression in 3.4 will have 
consequences.

--
status: closed - open

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



[issue20897] @abstractmethod does not enforce method signatures

2014-03-18 Thread Claudiu.Popa

Claudiu.Popa added the comment:

Hello. In 3.3 you can instantiate META class, because it does not properly say 
that it wants abc.ABCMeta as a metaclass. For this, you have to write your 
class as such:

class META(metaclass=abc.ABCMeta):
@abc.abstractmethod
def _junk(self):
   ...

--
nosy: +Claudiu.Popa

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



[issue7980] time.strptime not thread safe

2014-03-18 Thread Romuald Brunet

Changes by Romuald Brunet romuald.bru...@gmail.com:


--
nosy: +Romuald

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



[issue20967] hashlib memory leak

2014-03-18 Thread Adrian Teng

New submission from Adrian Teng:

A particular usage pattern of hashlib will cause a memory leak.

This leaks:
import hashlib
import sys

if __name__ == '__main__':
data_sha1 = hello world
data_md5 = hello world
for i in xrange(int(1e6)):
hashlib.sha1(data_sha1)
hashlib.md5(data_md5)

if i % 1000 == 0:
print sys.getrefcount(data_sha1), ,, sys.getrefcount(data_md5)

---
this doesn't leak:

import hashlib
import sys


if __name__ == '__main__':
data_sha1 = hello world
data_md5 = hello world
for i in xrange(int(1e6)):
sha1 = hashlib.sha1()
sha1.update(data_sha1)
md5 = hashlib.md5()
md5.update(data_md5)

if i % 1000 == 0:
print sys.getrefcount(data_sha1), , , sys.getrefcount(data_md5)


See attached for leak memory profiling in linux

--
components: Library (Lib)
files: memoryleak_min.py
messages: 213961
nosy: ateng
priority: normal
severity: normal
status: open
title: hashlib memory leak
type: resource usage
versions: Python 2.7
Added file: http://bugs.python.org/file34489/memoryleak_min.py

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



[issue20897] @abstractmethod does not enforce method signatures

2014-03-18 Thread R. David Murray

R. David Murray added the comment:

The fact that you say the method is _junk(self) and say the other classes 
don't override it makes me think you are thinking that methods with the same 
name are different from a subclasses perspective if they have different 
signatures.  In Python this is not true.  You cannot have methods with the same 
name and different signatures in the same class, so in Python override means 
has a method with the same name.  Therefore the implementation is currently 
behaving in accordance with the documentation.

Checking for compatible signatures would be a new feature by our rules 
regardless of whether it is considered an API bug or not.  This is because it 
could cause existing working programs to break, and so can't be changed in a 
maintenance release.

I think I agree with Terry that this should be discussed on python-ideas first, 
although insofar as ABCs are useful, it seems like a reasonable feature to me.  
And probably not hard to do now that we have signature objects.

--
nosy: +r.david.murray

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



[issue19009] Enhance HTTPResponse.readline() performance

2014-03-18 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

LGTM.

--
stage: patch review - commit review
versions: +Python 3.5 -Python 3.4

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



[issue20968] mock.MagicMock does not mock __truediv__

2014-03-18 Thread Johannes Baiter

New submission from Johannes Baiter:

It seems that when creating a MagicMock the magic '__truediv__' method is not 
replaced with a mock:

 import mock
 foo = mock.MagicMock()
 foo / 2
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: unsupported operand type(s) for /: 'MagicMock' and 'int'

The same thing works perfectly fine when using the third party module in Python 
2.7, since the 2.x '__div__' seems to be mocked:

 import mock
 foo = mock.MagicMock()
 foo/2
MagicMock name='mock.__div__()' id='139760595027088'

To clarify the context, I am trying to mock a 'pathlib.Path' object in my 
unittest, which overloads the division operator, i.e. implements '__truediv__'.

--
components: Library (Lib)
messages: 213964
nosy: Johannes.Baiter
priority: normal
severity: normal
status: open
title: mock.MagicMock does not mock __truediv__
type: behavior
versions: Python 3.4

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



[issue20897] @abstractmethod does not enforce method signatures

2014-03-18 Thread Eric Snow

Eric Snow added the comment:

Both abstractnethod and abstractproperty work by setting __isabstractmethod__ 
to True on the decorated function.  Then type.__new__ looks for any attributes 
of the current class (including inherited ones) that have __isabstractmethod__ 
set to True.  The signature of abstract methods is not checked/enforced.  In 
fact the overriding attribute doesn't even have to be a method at all.  PEP 
3119 doesn't say much about this.  I expect it is the way the way it is for 
performance reasons.

As to SuperSubber working in Python 3, don't forget that metaclasses are 
declared in the class signature:

class SuperSubber(META):
pass

Doing things like enforcing signatures is doable, but would require some other 
mechanism.  If you want to pursue this further I recommend you take it to the 
python-ideas mailing list.

--
nosy: +eric.snow

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



[issue20966] Documentation Link for Python Tkinter Resources is currently broken

2014-03-18 Thread Roundup Robot

Roundup Robot added the comment:

New changeset be1e015a8405 by Zachary Ware in branch '2.7':
Issue #20966: Fix Tkinter Resources link
http://hg.python.org/cpython/rev/be1e015a8405

New changeset f28f63c5d30a by Zachary Ware in branch '3.4':
Issue #20966: Fix Tkinter Resources link
http://hg.python.org/cpython/rev/f28f63c5d30a

New changeset f8b40d33e45d by Zachary Ware in branch 'default':
Closes #20966: Fix Tkinter Resources link (merge from 3.4)
http://hg.python.org/cpython/rev/f8b40d33e45d

--
nosy: +python-dev
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

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



[issue20966] Documentation Link for Python Tkinter Resources is currently broken

2014-03-18 Thread Zachary Ware

Zachary Ware added the comment:

Fixed, thanks for the report!

--
nosy: +zach.ware
type: resource usage - behavior
versions:  -Python 3.1, Python 3.2, Python 3.3

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



[issue20897] @abstractmethod does not enforce method signatures

2014-03-18 Thread Eric Snow

Eric Snow added the comment:

Oops, typos.

 Both abstractmethod and abstractproperty work by setting
__isabstractmethod__ to True on the decorated function.  Then type.__new__

That should be type.__call__ or object.__new__, I don't remember which.

 looks for any attributes of the current class (including inherited ones)
that have __isabstractmethod__ set to True...

 As to SuperSubber working in Python 3, don't forget that metaclasses are
declared in the class signature:

 class SuperSubber(META):
 pass

That should be:

class META(metaclass=abc.ABCMeta):

--

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



[issue20918] Logging of logging exceptions can fail in 3.4 if args are unprintable

2014-03-18 Thread R. David Murray

R. David Murray added the comment:

Did you reopen the issue accidentally?  The bug has been fixed.

--
status: open - closed

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



[issue20968] mock.MagicMock does not mock __truediv__

2014-03-18 Thread Johannes Baiter

Johannes Baiter added the comment:

Attached is a patch that fixes the issue for me.

--
keywords: +patch
Added file: http://bugs.python.org/file34490/mock_truediv.diff

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




[issue20969] Author of EPUB version of Python docs is set to Unknown instead of PSF

2014-03-18 Thread Christian Clauss

New submission from Christian Clauss:

http://docs.python.org/3/download.html has an EPUB version of the Python docs 
but the Author of the document is set to Unknown so this text appears on the 
cover page and is repeated on the top of every other page throughout the 
document (in the iBooks app at least). Perhaps something like The Python 
Software Foundation would be better than Unknown.

To fix this issue, both Makefile and make.bat in 
https://github.com/python/pythondotorg/blob/master/docs would need to be 
modified to add the Sphinx -A option to the EPUB make. Perhaps the Release (-R) 
and/or Version (-V) should also be set to the relevant Python version number.

--
assignee: docs@python
components: Documentation
messages: 213972
nosy: Christian.Clauss, docs@python
priority: normal
severity: normal
status: open
title: Author of EPUB version of Python docs is set to Unknown instead of PSF
type: enhancement
versions: Python 3.4

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



[issue20968] mock.MagicMock does not mock __truediv__

2014-03-18 Thread Johannes Baiter

Johannes Baiter added the comment:

I just noticed that I put the magic method names in the wrong place in the 
patch.
Attached is a fix that adds 'truediv' to the global 'numberics' variable, this 
way '__rtruediv__' and '__itruediv__' will be correctly mocked as well.

--
Added file: http://bugs.python.org/file34491/mock_truediv_numerics.diff

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



[issue20746] test_pdb fails in refleak mode

2014-03-18 Thread Xavier de Gaye

Xavier de Gaye added the comment:

test_statistics also defines a load_tests() function that builds unittest tests 
from doctests with doctest.DocTestSuite() and also fails in refleak mode. The 
above regrtest.diff patch also fixes the test_statistics in refleak mode.

--

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



[issue20897] @abstractmethod does not enforce method signatures

2014-03-18 Thread R. David Murray

R. David Murray added the comment:

Or, in 3.4, class META(abc.ABC).

OK, since Eric agrees that this is python-ideas material, we'll close this 
issue for now.  If you get consensus for it on python-ideas, the issue can be 
reopened (or a new one started, whichever turns out to be appropriate).

--
resolution:  - later
stage: needs patch - committed/rejected
status: open - closed
type: behavior - enhancement

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



[issue15100] Race conditions in shutil.copy, shutil.copy2 and shutil.copyfile

2014-03-18 Thread Jim Jewett

Jim Jewett added the comment:

Is this really only 3.4?  Since it is security-related, it seems like it should 
be at least considered for older versions as well.

--
nosy: +Jim.Jewett

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



[issue16043] xmlrpc: gzip_decode has unlimited read()

2014-03-18 Thread Jim Jewett

Jim Jewett added the comment:

I'm putting it back to release blocker, because 3.3 should decide whether to 
fix it/call it security/remove itself from the list.

The patch contains several small changes.  I like the spelling fix (gsip - 
gzip) in a test method, but otherwise, I prefer the alternative solution of an 
additional function parameter with a default.

I would prefer that the marker for no limit be None, rather than -1, 0, or 
anything less than 0.

I also don't see the point of raising a too-much-data ValueError *after* 
decoding.  While that *might* mean we set the default too low, all we would 
really know for sure is that there would be a bug in gzip.GzipFile().read -- 
and ValueError suggests otherwise.

--
nosy: +Jim.Jewett
priority: critical - release blocker

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



[issue20967] hashlib memory leak

2014-03-18 Thread STINNER Victor

STINNER Victor added the comment:

I'm unable to reproduce your issue with Python 2.7.5:

$ python memoryleak_min.py 
[256720896.0, 15740928.0, 139264.0]
[256724992.0, 15962112.0, 139264.0]
[256724992.0, 15966208.0, 139264.0]
[256724992.0, 15966208.0, 139264.0]
(...)
[256724992.0, 15966208.0, 139264.0]

$ python2.7 your example
5 , 5
5 , 5
(...)
5 , 5

What is your exact Python version? What is your OS? OS version?

--
nosy: +haypo

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



[issue20967] hashlib memory leak

2014-03-18 Thread Adrian Teng

Adrian Teng added the comment:

Python 2.7.3, Red Hat Enterprise Linux Server release 5.5, with kernal 
2.6.18-308.el5

--

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



[issue1599254] mailbox: other programs' messages can vanish without trace

2014-03-18 Thread Jim Jewett

Jim Jewett added the comment:

What is the status here?

As best I can tell from a skim, 

(a)  It should be broken into at least three separate issues.  (Though maybe 
some can just be closed instead of separated?)

(b)  None of them are security holes, so we missed 2.5 and 2.6, and should now 
remove 3.2 and possibly 3.3.

(c)  There are patches with at least test cases (and maybe fixes) for all 
identified issues.

(d)  None of these patches have been applied, so we should probably add 3.4 and 
and 3.5 to the affected list, and then apply at least the test cases and the 
uncontroversial fixes.

(e) Ideally, David Watson and/or Andrew Kuchling should sign off on which 
patches are uncontroversial.

--
nosy: +Jim.Jewett

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



  1   2   >