473,378 Members | 1,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

filter and map / deprecated?

I read in PEP 279 the following comment by GvR:

"filter and map should die and be subsumed into list
comprehensions, not grow more variants."

Actually, I am using 'filter' and 'map' a lot in my scripts
(not really because they are necessary, but more because I
like them). Should I avoid the usage of 'filter' and 'map'
in the future? The above comment by GvR makes me a little
bit afraid that they will become deprecated one day and that
I will have to change many of my scripts then.

--
mailto: logan@phreaker(NoSpam).net

Jul 18 '05 #1
5 5443

"Logan" <lo***@phreaker.nospam> wrote in message news:pa****************************@phreaker.nospa m...
I read in PEP 279 the following comment by GvR:

"filter and map should die and be subsumed into list
comprehensions, not grow more variants."

Actually, I am using 'filter' and 'map' a lot in my scripts
(not really because they are necessary, but more because I
like them). Should I avoid the usage of 'filter' and 'map'
in the future? The above comment by GvR makes me a little
bit afraid that they will become deprecated one day and that
I will have to change many of my scripts then.


You will have to port and and test your scripts on the new Python.
You aren't going to use them untested, are you? In case of
filter & map you will just have to (my guess) insert:
from legacy import filter, map
Using filter & map these days is discouraged, use itertools
module.

Anyway I think before they disappear they should be removed
from documentation and _books_ first. I mean old books should
become obsolete, new books and documentation should briefly
mention them in the legacy chapter. These are should be no
trace of them in the main chapters. And then the functions can
be actually removed from the Python core. I beleive this is the
least painful way to get rid of them. The cost of keeping them
in the core is very low, the main problem is documentation.
So the process of deprecitation should focus on the documentation.

-- Serge.
Jul 18 '05 #2

"Logan" <lo***@phreaker.nospam> wrote in message
news:pa****************************@phreaker.nospa m...
I read in PEP 279 the following comment by GvR:

"filter and map should die and be subsumed into list
comprehensions, not grow more variants."

Actually, I am using 'filter' and 'map' a lot in my scripts
(not really because they are necessary, but more because I
like them). Should I avoid the usage of 'filter' and 'map'
in the future? The above comment by GvR makes me a little
bit afraid that they will become deprecated one day and that
I will have to change many of my scripts then.
My understanding is that they are on the list of functions
to go away in 3.0. Guido would like to get rid of all five
of the "functional programming" mechanisms. So far,
filter, map and apply have acceptable substitutes, and
the arm waving brigade is claiming that the new sum()
function will handle all "real" use cases for reduce. (You
can tell I don't agree, but that doesn't seem to be
relevant.) Lambda is the odd man out at this point.
I believe it's waiting on an acceptable syntax
for blocks, which seems to be very hard to do.

John Roth
--
mailto: logan@phreaker(NoSpam).net

Jul 18 '05 #3
Also, I suppose if you were *really* in a rush and wanted to get old code
working, then all you'd have to do is add something like this to it:

def map( func, seq ): return [ func(x) for x in seq ]
def filter( func, seq ): return [ x for x in seq if func(x) ]

This will probably be less efficient than Serge's solution. It is probably
also better to have that self-documenting "from legacy ..." in there, to
boot.

I think after a using list comprehensions for a while, they become a lot
more comfortable though, so it is not such a bad thing to develop the habit
of using them instead. Then, in the fullness of time, map() and filter()
will begin to look funny.
Jul 18 '05 #4

"Logan" <lo***@phreaker.nospam> wrote in message
news:pa****************************@phreaker.nospa m...
I read in PEP 279 the following comment by GvR:

"filter and map should die and be subsumed into list comprehensions, not grow more variants."

Actually, I am using 'filter' and 'map' a lot in my scripts (not really because they are necessary, but more because I like them). Should I avoid the usage of 'filter' and 'map' in the future? The above comment by GvR makes me a little bit afraid that they will become deprecated one day and that I will have to change many of my scripts then.


Removing filter, map, etc, totally would be a
contentious and controversial move and would make
many people unhappy. I do not anticipate it.

It has been proposed on PyDev that they be moved
to a 'functional' module (name not yet decided),
perhaps with other stuff added, and I believe that
Guido said he would be amenable to that. This I
do anticipate. The threshhold for being in a
module is much lower than the threshhold for being
added to and eventually for remaining in the
builtins.

So I would continue with your preference with the
expectation that some years from now you would
have to run 2.x scripts through a search and
replace script to run them with Python 3. But I
expect that will be true anyway to cope with other
changes. I also expect that people will use
2.final for years after the arrival of 3.0 (Just
as 1.5.2 is still in use today.)

Terry J. Reedy
Jul 18 '05 #5
> I read in PEP 279 the following comment by GvR:

"filter and map should die and be subsumed into list
comprehensions, not grow more variants."

Actually, I am using 'filter' and 'map' a lot in my scripts
(not really because they are necessary, but more because I
like them). Should I avoid the usage of 'filter' and 'map'
in the future? The above comment by GvR makes me a little
bit afraid that they will become deprecated one day and that
I will have to change many of my scripts then.


Until Py3.0, we are shying away from deprecating things.
apply(), buffer(), coerce(), and intern() were moved to a
separate page in the docs for obsolete or non-essential stuff
but there are no deprecations.

The itertools variants of filter and map are proving to be
popular and will likely be around for a long time. I suggest
using them instead of the builtins since they are memory friendly
and scale-up nicely.
Raymond Hettinger
Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Uwe Mayer | last post by:
Hi, Why is the UserDict module is deprecated after Python 2.2. The application of it I have in mind is, i.e. multiple inheritance from "file" and "dic" - which is not possible. If I used...
2
by: gf gf | last post by:
I read that lower() is deprecated. Unfortunately, I can't find the preferred way of lowercasing a string. What is it? Thanks PS Please cc me on all responses.
26
by: puzzled | last post by:
Okay, so my subject sounds a bit crass. As much as I'd like to totally embrace css and avoid "deprecated" usage, sometimes the deprecated stuff is so much easier and more effective. Plus, it at...
4
by: Lieven | last post by:
I'm trying to use is_sorted. When I do #include<algo.h>, I get: /usr/include/g++/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated...
45
by: Matt Parkins | last post by:
Hi, (I realise this probably isn't precisely the right group for this - could someone direct me to the appropriate group to post this question? - thanks !) I'm using Visual C++ 2005 Express...
9
by: Robert | last post by:
Hi, Currently I am using argument.callee.caller.arguments to get the arguments of the caller function, but Firefox complains that arguments (of Function) is deprecated. Is there a way to get...
3
by: Ben Rush | last post by:
When I compile my solution I get the following output - NET 2003\Vc7\atlmfc\include\atlwin.h(2027) : warning C4995: 'wsprintf': name was marked as #pragma deprecated C:\Program Files\Microsoft...
3
by: Tony | last post by:
At http://www.quirksmode.org/js/placejs.html I found a discussion on how & where to place your javascript. Toward the bottom of the page, PPK has a section titled Deprecated: Direct JavaScripts,...
5
by: Scirious | last post by:
People, how many deprecated methods have really been removed and no longer exists? TIA, Scirious.
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.