Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 167499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:17:09+00:00 2026-05-11T12:17:09+00:00

What is the difference between: some_list1 = [] some_list1.append(something) and some_list2 = [] some_list2

  • 0

What is the difference between:

some_list1 = [] some_list1.append('something') 

and

some_list2 = [] some_list2 += ['something'] 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T12:17:10+00:00Added an answer on May 11, 2026 at 12:17 pm

    For your case the only difference is performance: append is twice as fast.

    Python 3.0 (r30:67507, Dec  3 2008, 20:14:27) [MSC v.1500 32 bit (Intel)] on win32 Type 'help', 'copyright', 'credits' or 'license' for more information. >>> import timeit >>> timeit.Timer('s.append('something')', 's = []').timeit() 0.20177424499999999 >>> timeit.Timer('s += ['something']', 's = []').timeit() 0.41192320500000079  Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type 'help', 'copyright', 'credits' or 'license' for more information. >>> import timeit >>> timeit.Timer('s.append('something')', 's = []').timeit() 0.23079359499999999 >>> timeit.Timer('s += ['something']', 's = []').timeit() 0.44208112500000141 

    In general case append will add one item to the list, while += will copy all elements of right-hand-side list into the left-hand-side list.

    Update: perf analysis

    Comparing bytecodes we can assume that append version wastes cycles in LOAD_ATTR + CALL_FUNCTION, and += version — in BUILD_LIST. Apparently BUILD_LIST outweighs LOAD_ATTR + CALL_FUNCTION.

    >>> import dis >>> dis.dis(compile('s = []; s.append('spam')', '', 'exec'))   1           0 BUILD_LIST               0               3 STORE_NAME               0 (s)               6 LOAD_NAME                0 (s)               9 LOAD_ATTR                1 (append)              12 LOAD_CONST               0 ('spam')              15 CALL_FUNCTION            1              18 POP_TOP              19 LOAD_CONST               1 (None)              22 RETURN_VALUE >>> dis.dis(compile('s = []; s += ['spam']', '', 'exec'))   1           0 BUILD_LIST               0               3 STORE_NAME               0 (s)               6 LOAD_NAME                0 (s)               9 LOAD_CONST               0 ('spam')              12 BUILD_LIST               1              15 INPLACE_ADD              16 STORE_NAME               0 (s)              19 LOAD_CONST               1 (None)              22 RETURN_VALUE 

    We can improve performance even more by removing LOAD_ATTR overhead:

    >>> timeit.Timer('a('something')', 's = []; a = s.append').timeit() 0.15924410999923566 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What the difference between Application(some-object) and Cache(some-object) in ASP.NET?
What is the difference between encrypting some data vs signing some data (using RSA)?
Can some one explain to me the difference between categories and inheritance in Objective
Can anyone explain the difference between the types mentioned above and some sample usage
What is the difference between early and late binding?
Is there any difference between int on_exit(void (*function)(int , void *), void *arg); and
Is there a performance difference between i++ and ++i if the resulting value is
What is actually the difference between these two casts? SomeClass sc = (SomeClass)SomeObject; SomeClass
What is the difference between TrueType fonts and Type-1 fonts?
Can anyone recommend some good resources that highlight the differences between Oracle and the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.