addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1light-bulblinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Re: [nycpython] question about list.insert()

From: Jordan P
Sent on: Saturday, August 14, 2010 1:22 PM
Holy inefficiency, Batman! I had no idea that list.insert was linear!
David: I am actually dealing with huge lists. This is part of a project for school, so the code may actually be analyzed by the prof for efficiency, and he may well throw 1,000,000 values at it.

Also, I believe that a=b=2 in python is subtly different than C's implementation. I think python implements this as a special case (chained = operators), whereas in C, it is merely an artifact of almost all operations evaluating as their result. For example:

a = ( b = 3 ) is a syntax error in python, yet works as expected in C because (b = 3) will actually evaluate to 3.

I hear what everyone is saying, it's a design decision. So, yes, one could easily implement helper functions to call list.insert and return the list (or subclass list). I guess that's just what one has to do in python to get this behavior.

Thanks for the explanations, I hope everyone has relaxing weekends!

On Sat, Aug 14, 2010 at 12:25 PM, David Christian <[address removed]> wrote:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy