[ python-Feature Requests-1281053 ] non-sequence map() arguments for optimization

SourceForge.net noreply at sourceforge.net
Sat Sep 3 01:30:05 CEST 2005


Feature Requests item #1281053, was opened at 2005-09-02 16:30
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=1281053&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
Submitted By: Ecnassianer of the Green Storm (ecnassianer)
Assigned to: Nobody/Anonymous (nobody)
Summary: non-sequence map() arguments for optimization

Initial Comment:
I'm trying to optimize some code thats similiar to this:

anObject = someConstructor() # This isn't a sequence
myList = myListMaker()  # This IS a sequence

for items in myList:
     function(items, anObject)


I'd like to be able to do this:
map(function, myList, anObject)

But the map function takes two lists, so I have to do
somethign like this:

list2 = []
for x in range(len(myList)):
     list2.append(anObject)
map(function, myList, list2)

But intializing list2 kind of defeats the purpose of
optimization. I was looking for some way to convince
anObject that it was really a list containing a lots of
entries of itself, but couldn't find anything in the API.

What I'd love to have is a version of the map function
which takes a function, a sequence, and an object as
arguments and calls the function with the first
argument as an element in the sequence, and the second
element as the object for as many times as their are
items in the sequence. 

(Note: Currently the API says if you pass sequences of
unequal lenghths to map, it uses None to fill up the
rest of the calls)

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1281053&group_id=5470


More information about the Python-bugs-list mailing list