Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > RE: Python is faster than C

Reply
Thread Tools

RE: Python is faster than C

 
 
Robert Brewer
Guest
Posts: n/a
 
      04-04-2004
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

 
Reply With Quote
 
 
 
 
Isaac To
Guest
Posts: n/a
 
      04-05-2004
>>>>> "Robert" == Robert Brewer <(E-Mail Removed)> writes:

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

Perhaps the OP likes Haskell more than Python.

Regards,
Isaac.
 
Reply With Quote
 
 
 
 
Andrew Dalke
Guest
Posts: n/a
 
      04-05-2004
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
http://www.velocityreviews.com/forums/(E-Mail Removed)



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: Wow, Python much faster than MatLab Doran, Harold Python 10 01-01-2007 06:56 PM
Wow, Python much faster than MatLab Stef Mientki Python 11 01-01-2007 02:05 AM
Lisp development with macros faster than Python development?.. seberino@spawar.navy.mil Python 37 07-11-2005 02:10 PM
Python is faster than C Armin Rigo Python 36 04-06-2004 04:10 PM
Re: Python is faster than C Armin Rigo Python 6 04-05-2004 04:33 PM



Advertisments