[ python-Feature Requests-1618676 ] Improve list comprehensions to Language Integrated Query?

2006-12-19 Thread SourceForge.net
Feature Requests item #1618676, was opened at 2006-12-19 12:08
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1618676&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: JettLogic (jettlogic)
Assigned to: Nobody/Anonymous (nobody)
Summary: Improve list comprehensions to Language Integrated Query?

Initial Comment:
Hi,

A feature idea (shall put to mailing list discussion sometime), is to extend 
list comprehensions to many uses of SQL or XQuery unnecessary.  

The benefit of language integration over passing SQL/XQuery strings to external 
libraries would be making code agnostic to the source of the data: in-memory 
tables and trees could be queried just like a relational DB or XML.  An "order 
by" could be more efficient than sorted(f(x) for x in y).

Of course list comprehensions do much of the C#-style LINQ already, but they 
can't (easily) do joins or "select x from a, y from b" type queries, or return 
XML a la XQuery.

On the library side, DBAPI helps make code independent of any particular 
database, and sqlite in 2.5 means in-memory tables (lists of tuples) aren't 
really necessary.

If worthwhile, implementation would probably be best suited to PyPy.

C# Example from http://en.wikipedia.org/wiki/Language_Integrated_Query

var q = from o in db.Orders, c in db.Customers
where o.Quality == "200" && (o.CustomerID == c.CustomerID)
select new { o.DueDate, c.CompanyName, c.ItemID, c.ItemName };

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1618676&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Feature Requests-1618676 ] Promote list comprehensions to Language Integrated Query?

2006-12-19 Thread SourceForge.net
Feature Requests item #1618676, was opened at 2006-12-19 12:08
Message generated for change (Settings changed) made by jettlogic
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1618676&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: JettLogic (jettlogic)
Assigned to: Nobody/Anonymous (nobody)
>Summary: Promote list comprehensions to Language Integrated Query?

Initial Comment:
Hi,

A feature idea (shall put to mailing list discussion sometime), is to extend 
list comprehensions to many uses of SQL or XQuery unnecessary.  

The benefit of language integration over passing SQL/XQuery strings to external 
libraries would be making code agnostic to the source of the data: in-memory 
tables and trees could be queried just like a relational DB or XML.  An "order 
by" could be more efficient than sorted(f(x) for x in y).

Of course list comprehensions do much of the C#-style LINQ already, but they 
can't (easily) do joins or "select x from a, y from b" type queries, or return 
XML a la XQuery.

On the library side, DBAPI helps make code independent of any particular 
database, and sqlite in 2.5 means in-memory tables (lists of tuples) aren't 
really necessary.

If worthwhile, implementation would probably be best suited to PyPy.

C# Example from http://en.wikipedia.org/wiki/Language_Integrated_Query

var q = from o in db.Orders, c in db.Customers
where o.Quality == "200" && (o.CustomerID == c.CustomerID)
select new { o.DueDate, c.CompanyName, c.ItemID, c.ItemName };

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1618676&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1618455 ] HMAC can get a 6x performance increase easily

2006-12-19 Thread SourceForge.net
Bugs item #1618455, was opened at 2006-12-18 18:12
Message generated for change (Comment added) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1618455&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 5
Private: No
Submitted By: Ben Maurer (bmaurer)
>Assigned to: A.M. Kuchling (akuchling)
Summary: HMAC can get a 6x performance increase easily

Initial Comment:
The attached patch increases the performance of HMAC by a factor of 6. It does 
so by avoiding useing join/map in the strxor and using a lookup table. It would 
be faster just to do xor at the string level, but it's not clear that can be 
done without help from C.

--

>Comment By: A.M. Kuchling (akuchling)
Date: 2006-12-19 09:16

Message:
Logged In: YES 
user_id=11375
Originator: NO

Thanks for your patch; I've modified it to remove _strxor() completely and
applied the change as rev. 53065.  

When I tried a trivial benchmark, the speed improvement wasn't anywhere
near 6X, and was more like 7%.  The patch is still worth applying because
it also simplifies the code.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1618455&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1613651 ] recv_into not documented

2006-12-19 Thread SourceForge.net
Bugs item #1613651, was opened at 2006-12-11 21:29
Message generated for change (Comment added) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1613651&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.5
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Eric Huss (ehuss)
>Assigned to: A.M. Kuchling (akuchling)
Summary: recv_into not documented

Initial Comment:
The recv_into socket method does not appear to be documented in the Library 
Reference.


--

>Comment By: A.M. Kuchling (akuchling)
Date: 2006-12-19 09:29

Message:
Logged In: YES 
user_id=11375
Originator: NO

I've added descriptions for these two methods to the trunk in rev. 53066,
and will backport to 25-maint once I've verified that my markup is
correct.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1613651&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1603424 ] subprocess.py (py2.5) wrongly claims py2.2 compatibility

2006-12-19 Thread SourceForge.net
Bugs item #1603424, was opened at 2006-11-26 20:07
Message generated for change (Settings changed) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1603424&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Tim Wegener (twegener)
>Assigned to: Peter Åstrand (astrand)
Summary: subprocess.py (py2.5) wrongly claims py2.2 compatibility

Initial Comment:
From the comments in subprocess.py (py2.5):
# This module should remain compatible with Python 2.2, see PEP 291.

However, using it from Python 2.2 gives:
NameError: global name 'set' is not defined

(set built-in used on line 1005)

The subprocess.py in py2.4 was 2.2 compatible. 

Either the compatibility comment should be removed/amended or compatibility 
fixed. 


--

Comment By: Robert Carr (racarr)
Date: 2006-12-05 10:10

Message:
Logged In: YES 
user_id=1649655
Originator: NO

Index: subprocess.py
===
--- subprocess.py   (revision 52918)
+++ subprocess.py   (working copy)
@@ -1004,8 +1004,8 @@

 # Close pipe fds.  Make sure we don't close the same
 # fd more than once, or standard fds.
-for fd in set((p2cread, c2pwrite,
errwrite))-set((0,1,2)):
-if fd: os.close(fd)
+for fd in (p2cread,c2pwrite,errwrite):
+if fd not in (0,1,2): os.close(fd)

 # Close all other fds, if asked for
 if close_fds:

Fixed?

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1603424&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1604851 ] subprocess.Popen closes fds for sys.stdout or sys.stderr

2006-12-19 Thread SourceForge.net
Bugs item #1604851, was opened at 2006-11-28 17:17
Message generated for change (Settings changed) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1604851&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nishkar Grover (ngrover)
>Assigned to: Peter Åstrand (astrand)
Summary: subprocess.Popen closes fds for sys.stdout or sys.stderr

Initial Comment:
I found a problem in subprocess.Popen's _execute_child() method for POSIX, 
where the child process will close the fds for sys.stdout and/or sys.stderr if 
I use those as stdout and/or stderr when creating a subprocess.Popen object.

Here's what I saw by default when using the 2.4.4 version of Python...

% ./python
Python 2.4.4 (#1, Nov 28 2006, 14:08:29)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import sys, subprocess
>>> uname = subprocess.Popen('uname -a', shell=True, stdout=sys.stdout)
>>> uname: write error: Bad file descriptor

>>>

Then, I updated subprocess.py and made the following changes...

% diff subprocess.py subprocess.py.orig
924c924
< # fd more than once and don't close sys.stdout or 
sys.stderr.
---
> # fd more than once.
927c927
< if c2pwrite and c2pwrite not in (p2cread, 
sys.stdout.fileno(), sys.stderr.fileno()):
---
> if c2pwrite and c2pwrite not in (p2cread,):
929c929
< if errwrite and errwrite not in (p2cread, c2pwrite, 
sys.stdout.fileno(), sys.stderr.fileno()):
---
> if errwrite and errwrite not in (p2cread, c2pwrite):

After that, I saw the following...

% ./python
Python 2.4.4 (#1, Nov 28 2006, 14:08:29)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import sys, subprocess
>>> uname = subprocess.Popen('uname -a', shell=True, stdout=sys.stdout)
>>> Linux schnauzer 2.6.9-42.0.2.ELsmp #1 SMP Thu Aug 17 18:00:32 EDT 2006 i686 
>>> i686 i386 GNU/Linux

>>>

I'm attaching the modified version of subprocess.py. Please consider adding 
this fix to future versions of Python. Thanks!

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1604851&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1615376 ] subprocess doesn\'t handle SIGPIPE

2006-12-19 Thread SourceForge.net
Bugs item #1615376, was opened at 2006-12-13 19:21
Message generated for change (Settings changed) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1615376&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Mark Diekhans (diekhans)
>Assigned to: Peter Åstrand (astrand)
>Summary: subprocess doesn\'t handle SIGPIPE

Initial Comment:
subprocess keeps other side of child pipe open, making
use of SIGPIPE to terminate writers in a pipeline
not possible.

This is probably a matter of documentation or
providing a method to link up processes, as 
the parent end of the pipe must remain open
until it is connected to the next process in
the pipeline.

An option to enable sigpipe in child would be
nice.

Simple example attached.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1615376&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1597798 ] Modules/readline.c fails to compile on AIX 4.2

2006-12-19 Thread SourceForge.net
Bugs item #1597798, was opened at 2006-11-16 10:37
Message generated for change (Comment added) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1597798&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Build
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Mike Kent (mikekent)
Assigned to: Nobody/Anonymous (nobody)
Summary: Modules/readline.c fails to compile on AIX 4.2

Initial Comment:
Python 2.5 Modules/readline.c line 681 is:

return completion_matches(text, *on_completion);

on_completion is a function declared as:

static char *on_completion(char *text, int state);

completion_matches is a macro that expands to: 

rl_completion_matches((x), ((rl_compentry_func_t *)(y)))

SO, the second parameter to completion_matches should be a function pointer 
(on_completion), not the dereferenced function pointer that is currently passed 
to it (*on_completion).


--

>Comment By: A.M. Kuchling (akuchling)
Date: 2006-12-19 09:50

Message:
Logged In: YES 
user_id=11375
Originator: NO

Can you please provide a patch that fixes things?  It's difficult for us
to provide a patch that will fix the problem on AIX because we don't have
access to an AIX machine for testing.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1597798&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1593035 ] readline problem on ia64-unknown-linux-gnu

2006-12-19 Thread SourceForge.net
Bugs item #1593035, was opened at 2006-11-08 18:48
Message generated for change (Comment added) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1593035&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Kate Minola (kate01123)
Assigned to: Nobody/Anonymous (nobody)
Summary: readline problem on ia64-unknown-linux-gnu

Initial Comment:
On my ia64-unknown-linux-gnu machine, running
python-2.5, if I import the following code (foo.py) and
then try to do file name completion, I get a
segmentation fault. Specifically, if after importing
foo.py, if I type "im" and then [tab], I get a
segmentation fault.

I built python-2.5 from source using the default
values.  (All I did was "configure", then "make".)

This does NOT happen under python-2.4.4.

- foo.py --
try:
 import rlcompleter,readline
except ImportError:
 print '*** No readline support ***'
 pass
else:
 readline.set_history_length(1000)
 # parse and bind all these:
 rlcmds = ['tab: complete',
   r'"\M-p": history-search-backward',
   r'"\M-n": history-search-forward',
   r'"\C-p": history-search-backward',
   r'"\C-n": history-search-forward',
   r'"\e[A": history-search-backward',
   r'"\e[B": history-search-forward',
   'set show-all-if-ambiguous on',
   ]   
 map(readline.parse_and_bind,rlcmds)
---

%uname -a
Linux lepidus 2.4.21-sgi302r24 #1 SMP Fri Oct 22
22:43:12 PDT 2004 ia64 ia64 ia64 GNU/Linux
%
% ./python --version
Python 2.5
% 
% ./python 
Python 2.5 (r25:51908, Nov  8 2006, 15:40:13)
[GCC 4.1.1] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import foo
>>> impSegmentation fault (core dumped)
%
% gdb ./python
GNU gdb Red Hat Linux (6.0post-0.20040223.20rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public
License, and you are
welcome to change it and/or distribute copies of it
under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show
warranty" for details.
This GDB was configured as
"ia64-redhat-linux-gnu"...Using host libthread_db library
"/lib/tls/libthread_db.so.1".

(gdb) r
Starting program: /home/kate/sage/william/Python-2.5/python
[Thread debugging using libthread_db enabled]
[New Thread 2305843009213881680 (LWP 23166)]
Python 2.5 (r25:51908, Nov  8 2006, 15:40:13)
[GCC 4.1.1] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import foo
>>> im
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 2305843009213881680 (LWP 23166)]
0x2264ae90 in rl_complete_internal () from
/usr/lib/libreadline.so.4
(gdb) bt
#0  0x2264ae90 in rl_complete_internal () from
/usr/lib/libreadline.so.4
#1  0x22646d90 in rl_complete () from
/usr/lib/libreadline.so.4
#2  0x2263bc40 in _rl_dispatch_subseq () from
/usr/lib/libreadline.so.4
#3  0x2263b780 in _rl_dispatch () from
/usr/lib/libreadline.so.4
#4  0x2263af90 in readline_internal_char ()
from /usr/lib/libreadline.so.4
#5  0x in ?? ()
(gdb)


Kate Minola
University of Maryland, College Park





--

>Comment By: A.M. Kuchling (akuchling)
Date: 2006-12-19 09:51

Message:
Logged In: YES 
user_id=11375
Originator: NO

I wonder if this crash is related to the function pointer issue described
in
bug #1597798.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1593035&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1618455 ] HMAC can get a 6x performance increase easily

2006-12-19 Thread SourceForge.net
Bugs item #1618455, was opened at 2006-12-18 18:12
Message generated for change (Comment added) made by bmaurer
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1618455&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Closed
Resolution: Accepted
Priority: 5
Private: No
Submitted By: Ben Maurer (bmaurer)
Assigned to: A.M. Kuchling (akuchling)
Summary: HMAC can get a 6x performance increase easily

Initial Comment:
The attached patch increases the performance of HMAC by a factor of 6. It does 
so by avoiding useing join/map in the strxor and using a lookup table. It would 
be faster just to do xor at the string level, but it's not clear that can be 
done without help from C.

--

>Comment By: Ben Maurer (bmaurer)
Date: 2006-12-19 09:58

Message:
Logged In: YES 
user_id=660878
Originator: YES

The performance increase is if you call hmac.new a lot. I did a benchmark
on a relatively small amount of cleartext (50 bytes). This was actually
something I needed to use.

One thing I found -- reusing teh same hmac option helps *ALOT* the hmac
docs don't make it clear how much this will help.

--

Comment By: A.M. Kuchling (akuchling)
Date: 2006-12-19 09:16

Message:
Logged In: YES 
user_id=11375
Originator: NO

Thanks for your patch; I've modified it to remove _strxor() completely and
applied the change as rev. 53065.  

When I tried a trivial benchmark, the speed improvement wasn't anywhere
near 6X, and was more like 7%.  The patch is still worth applying because
it also simplifies the code.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1618455&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1603150 ] wave module forgets to close file on exception

2006-12-19 Thread SourceForge.net
Bugs item #1603150, was opened at 2006-11-26 08:59
Message generated for change (Comment added) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1603150&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: amerinese (amerinese)
Assigned to: Nobody/Anonymous (nobody)
Summary: wave module forgets to close file on exception

Initial Comment:
I am using python 2.4 on Windows XP SP2

The wave module function:
f = wave.open(file)

In the case that file is a path to the file and the file is not yet opened, 
wave.open(file) may raise an exception if the file is opened and it does not 
fulfill the format of a WAV file.  However, it forgets to close the file when 
the exception is raised keeping other functions from accessing the file (at 
least until the file is garbage collected).

The regular file opening idiom doesn't work
f = wave.open(file)
try:
   ## do something with the wav file
finally:
   f.close()
Since wave.open(file) raises an exception before return the file name, f can't 
be closed, but the file is open.

The reason I know this is because I try to delete the file if trying to open it 
raises an RIFF or not a WAV file exception and it claims the file is locked.

--

>Comment By: A.M. Kuchling (akuchling)
Date: 2006-12-19 14:59

Message:
Logged In: YES 
user_id=11375
Originator: NO

Try putting the Wave.open() inside the try...finally.



--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1603150&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1619060 ] bisect on presorted list

2006-12-19 Thread SourceForge.net
Bugs item #1619060, was opened at 2006-12-19 16:14
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1619060&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Extension Modules
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jeffrey C. Jacobs (timehorse)
Assigned to: Nobody/Anonymous (nobody)
Summary: bisect on presorted list

Initial Comment:
The python and c implementation of bisect do not support custom-sorted lists 
using the list.sort method.

In order to support an arbitrarily sorted list via sort(cmp, key, reverse), I 
have added 3 corresponding parameters to the bisect methods for bisection and 
insort (insert-sorted) corresponding to the parameters in sort.  This would be 
useful if a list is initially sorted by its sort method and then the client 
wishes to maintain the sort order (or reverse-sort order) while inserting an 
element.  In this case, being able to use the same, arbitrary binary function 
cmp, unary function key and boolean reverse flag to preserve the list order.

The change imposes 3 new branch conditions and potential no-op function calls 
for when key is None.  I have here implemented and partially tested the python 
implementation and if someone besides me would find this useful, I will update 
the _bisectmodule.c for this change as well.

The Heap functions may also find use of an arbitrary predicate function so I 
may look at that later, but because bisect goes hand in hand with sorting, I 
wanted to tackle that first.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1619060&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1619060 ] bisect on presorted list

2006-12-19 Thread SourceForge.net
Bugs item #1619060, was opened at 2006-12-19 16:14
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1619060&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Extension Modules
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jeffrey C. Jacobs (timehorse)
Assigned to: Nobody/Anonymous (nobody)
Summary: bisect on presorted list

Initial Comment:
The python and c implementation of bisect do not support custom-sorted lists 
using the list.sort method.

In order to support an arbitrarily sorted list via sort(cmp, key, reverse), I 
have added 3 corresponding parameters to the bisect methods for bisection and 
insort (insert-sorted) corresponding to the parameters in sort.  This would be 
useful if a list is initially sorted by its sort method and then the client 
wishes to maintain the sort order (or reverse-sort order) while inserting an 
element.  In this case, being able to use the same, arbitrary binary function 
cmp, unary function key and boolean reverse flag to preserve the list order.

The change imposes 3 new branch conditions and potential no-op function calls 
for when key is None.  I have here implemented and partially tested the python 
implementation and if someone besides me would find this useful, I will update 
the _bisectmodule.c for this change as well.

The Heap functions may also find use of an arbitrary predicate function so I 
may look at that later, but because bisect goes hand in hand with sorting, I 
wanted to tackle that first.

--

>Comment By: Raymond Hettinger (rhettinger)
Date: 2006-12-19 16:43

Message:
Logged In: YES 
user_id=80475
Originator: NO

I'm -1 on this patch.  At first blush it would seem nice to progagate
sort's notion of a key= function; however, sort() is an all at once
operation that can guarantee the function gets called only once per key. 
In contrast, bisect() is more granualar so consecutive calls may need to
invoke the same key= function again and again.  This is almost always the
the-wrong-way-to-do-it (the key function should be precomputed and either
stored separately or follow a decorate-sort pattern).  By including custom
sorting in bisect's API we would be diverting users away from better
approaches.

A better idea would be to create a recipe for a SortedList class that
performed pre-calculated custom keys upon insertion and maintained an
internal, decorated list.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1619060&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1619130 ] 64-bit Universal Binary build broken

2006-12-19 Thread SourceForge.net
Bugs item #1619130, was opened at 2006-12-19 15:22
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1619130&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Macintosh
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Thomas Treadway (treadway)
Assigned to: Jack Jansen (jackjansen)
Summary: 64-bit Universal Binary build broken

Initial Comment:
Hi,
I'm running into problem building a 4-way universal binary of python.
The following has cropped up on both python2.5 and python2.4.2

The configure goes OK, but the make bombs.
[2244]$  ./configure --prefix=$VISITPATH/python OPT="-fast -Wall \
-Wstrict-prototypes -fno-common -fPIC \
-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
-arch ppc -arch i386 -arch ppc64 -arch x86_64" \
LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk,\
-headerpad_max_install_names -arch ppc -arch i386 \
-arch ppc64 -arch x86_64"

. . .
[2245]$ make
gcc -c -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd 
-DNDEBUG -fast -Wall -Wstrict-prototypes -fno-common -fPIC -isysroot 
/Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 -arch ppc64 -arch x86_64  
-I. -I./Include   -DPy_BUILD_CORE -o Modules/python.o ./Modules/python.c
In file included from ./Include/Python.h:57In file included from 
./Include/Python.h:57,
 from ./Modules/python.c:3:
./Include/pyport.h:730:2: error: #error "LONG_BIT definition appears wrong for 
platform (bad gcc/glibc config?)."
,
 from ./Modules/python.c:3:
./Include/pyport.h:730:2: error: #error "LONG_BIT definition appears wrong for 
platform (bad gcc/glibc config?)."
lipo: can't figure out the architecture type of: /var/tmp//ccL3Ewl4.out
make: *** [Modules/python.o] Error 1

Comenting out the "#error" statement in pyport.h get me a little further
befor getting:
gcc -c -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd 
-DNDEBUG -fast -Wall -Wstrict-prototypes -fno-common -fPIC -isysroot 
/Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 -arch ppc64 -arch x86_64  
-I. -I./Include   -DPy_BUILD_CORE -o Python/mactoolboxglue.o 
Python/mactoolboxglue.c
In file included from 
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/DriverServices.h:32,
 from 
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:125,
  . . .
 from 
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Carbon.framework/Headers/Carbon.h:20,
 from ./Include/pymactoolbox.h:10,
 from Python/mactoolboxglue.c:27:
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/fp.h:1338:
 error: 'SIGDIGLEN' undeclared here (not in a function)
lipo: can't figure out the architecture type of: /var/tmp//ccEYbpTz.out
make: *** [Python/mactoolboxglue.o] Error 1

Seem Carbon doesn't support 64-bits!
Is there a solution?
   trt
--
Thomas R. Treadway
Computer Scientist
Lawrence Livermore Nat'l Lab
7000 East Avenue, L-159
Livermore, CA 94550-0611


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1619130&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1590891 ] random.randrange don't return correct value for big number

2006-12-19 Thread SourceForge.net
Bugs item #1590891, was opened at 2006-11-05 11:54
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1590891&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: MATSUI Tetsushi (mft)
Assigned to: Raymond Hettinger (rhettinger)
Summary: random.randrange don't return correct value for big number

Initial Comment:
Python 2.4.3 (#1, Oct  3 2006, 00:36:06)
[GCC 4.1.1 (Gentoo 4.1.1-r1)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import random
>>> random.randrange(1,
-1, -200)
267471051174796896L

Obviously, the result is not in the specified range;
1 < 267471051174796896,
-1 < 267471051174796896
and
(267471051174796896 - 1) % (-200) != 0.

I'm using 2.3.5 and 2.4.3, and their behaviors are
identical.
I haven't checked about 2.5.

--

>Comment By: Raymond Hettinger (rhettinger)
Date: 2006-12-20 01:43

Message:
Logged In: YES 
user_id=80475
Originator: NO

Thanks for the report.

Fixed in revision 53099.

--

Comment By: Armin Rigo (arigo)
Date: 2006-11-08 17:22

Message:
Logged In: YES 
user_id=4771

Oups.  If the interval is very large, the step is
ignored.  Patch attached...

--

Comment By: Josiah Carlson (josiahcarlson)
Date: 2006-11-08 11:45

Message:
Logged In: YES 
user_id=341410

2.5 has the same behavior.

One workaround (until it gets fixed) is to do the following...

def myrandrange(start, stop, step):
return start + random.randrange((stop-start)//step)*step

random.randrange should change to do some variant of the
above, given sane start, stop, step arguments.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1590891&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com