Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

- Multithreaded development; multiprocess is being favored (as well as event-driven) and there are some helpful modules for it

- Unicode (at least for Python 2)

- Debugging is a little behind other languages (pdb works)

- removal of map/filter in place of list comprehensions (they are certainly better but not faster)



> - Debugging is a little behind other languages (pdb works)

So do the numerous extensions/replacements for pdb, or the multiple graphical debuggers (e.g. PyCharm's, PyDev's, PuDB, WinPDB, Kodomo IDE's, Wing's, ...). Python doesn't have a time-traveling debugger à la OCaml, but that's about it as far as I can tell.

> removal of map/filter in place of list comprehensions (they are certainly better but not faster)

What are you talking about exactly? Because I find two possible interpretations of that phrase, and neither comes close to being correct.


Well, my mistake, map and filter are not faster than a list comprehension (at least not in 2.7)

My test case is: f = [x^2 for x in l if (x % 2) == 0] (and something similar with map and filter)

(where you read x^2 please consider x(double asterisk)2)

For 500k elements - xrange(500000) - this takes: 0.122527122498 (list comprehension) 0.145442008972 (map/filter)


map and filter still exist. reduce was demoted into the stdlib instead of being builtin in 3.x.

list comprehensions generalize to other types (generator expressions (aka "lazy sequences"), set comprehensions, dict compresions)

Compare this syntax (using dict comprehensions in 2.7):

  {k:v for k, v in something.iteritems() if v == 3}
to this syntax using map/filter:

  dict(filter(None, 
           filter(lambda x: x if x[1] == 3 else None,
           something.iteritems()))
More frustrating to me is that there isn't an imap/ifilter builtin (I understand that it's in stdlib, I'm just lazy).


> More frustrating to me is that there isn't an imap/ifilter builtin

FWIW, alongside the demotion of reduce to the stdlib Python 3 changed that, the builtin `map` and `filter` now return lazy "views" (as do e.g. `dict.items`, `dict.keys` and `dict.values`):

    # python 2
    >>> map(sys.stdout.write, ['foo', 'bar', 'baz'])
    foobarbaz[None, None, None]

    # python 3
    >>> map(sys.stdout.write, ['foo', 'bar', 'baz'])
    <map object at 0x10071cfd0>


I really wasn't awake when I wrote this, because that second example is awful. It should be:

  {k:v for k, v in something.iteritems() if v == 3}
vs

  dict(filter(lambda x: x[1] == 3, something.iteritems()))


An up vote just for Unicode in Python 2. It kills my life big time.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: