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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 117k
  • Answers 117k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need to use each(). next() only walks the DOM. May 11, 2026 at 10:43 pm
  • Editorial Team
    Editorial Team added an answer Taken from os.py on CPython 2.6: sys.modules['os.path'] = path from… May 11, 2026 at 10:42 pm
  • Editorial Team
    Editorial Team added an answer If you're not concerned about using a library, try Microsoft… May 11, 2026 at 10:42 pm

Related Questions

I was asked to look at some code for a friend. (I rightly hesitated
I'm getting some very strange behaviour with HttpWebRequest I hope someone can help me
We have a database library in C# that we can use like this: DatabaseConnection
A question about different methods of outputting html from PHP; what are the performance

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.