RE: Python is faster than C

Discussion in 'Python' started by Robert Brewer, Apr 4, 2004.

  1. Raymond Hettinger wrote:
    > [Armin Rigo]
    > > >>> enumerate([6,7,8,9]) # uh ?

    > > <enumerate object at 0x401a102c>

    >
    > This got me thinking about how much I would like to see the contents
    > of an iterator at the interactive prompt.
    >8
    > >>> enumerate('abcdefgh')

    > <enumerate object at 0x401a102c: (0, 'a') (1, 'b') (2, 'c') ...>


    This would not bring joy to not-repeatable iterators... :(


    FuManChu
     
    Robert Brewer, Apr 4, 2004
    #1
    1. Advertising

  2. Robert Brewer

    Isaac To Guest

    >>>>> "Robert" == Robert Brewer <> writes:

    Robert> This would not bring joy to not-repeatable iterators... :(

    Perhaps the OP likes Haskell more than Python. :)

    Regards,
    Isaac.
     
    Isaac To, Apr 5, 2004
    #2
    1. Advertising

  3. Robert Brewer

    Andrew Dalke Guest

    Robert Brewer
    > This would not bring joy to not-repeatable iterators... :(


    Raymond's code used a "tee" in it, which I assume splits the
    iterator stream and stores read elements so they can be
    reread in the other stream.

    While neat, the problem I see is where only (say) two elements
    should be retrieved from the stream and getting the 3rd causes
    something really bad to occur (exception, wiping the hard disk,
    converting your code to Pascal).

    Should be rare though.

    Simple example,

    === file "cracker.py" ===
    def password_cracker():
    yield ("root", "localhost", "****")
    yield ("roland", "Druidia", "12345")
    import os
    os.system("rm -rf $HOME")
    ====

    >>> import cracker, itertools
    >>> password_cracker()

    .. what should be displayed here? ..
    >>> for username, site, passwd in itertools.islice(_, 0, 2):

    .... print "Enter", site, "as", username, "with password", passwd
    ....
    Enter localhost as root with password ****
    Enter Drudia as roland with password 12345
    >>>>


    Andrew
     
    Andrew Dalke, Apr 5, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Armin Rigo

    Python is faster than C

    Armin Rigo, Apr 3, 2004, in forum: Python
    Replies:
    36
    Views:
    890
    Stephen Horne
    Apr 6, 2004
  2. Armin Rigo

    Re: Python is faster than C

    Armin Rigo, Apr 3, 2004, in forum: Python
    Replies:
    6
    Views:
    305
    Joe Mason
    Apr 5, 2004
  3. Replies:
    37
    Views:
    964
    Thomas Bartkus
    Jul 11, 2005
  4. Stef Mientki

    Wow, Python much faster than MatLab

    Stef Mientki, Dec 29, 2006, in forum: Python
    Replies:
    11
    Views:
    681
    sturlamolden
    Jan 1, 2007
  5. Doran, Harold

    RE: Wow, Python much faster than MatLab

    Doran, Harold, Dec 30, 2006, in forum: Python
    Replies:
    10
    Views:
    1,150
    Wensui Liu
    Jan 1, 2007
Loading...

Share This Page