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 4557072
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:27:23+00:00 2026-05-21T17:27:23+00:00

I understand that they are both essentially the same thing. But in terms of

  • 0

I understand that they are both essentially the same thing. But in terms of creating an empty list or dict, are there any differences?

  • 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. Editorial Team
    Editorial Team
    2026-05-21T17:27:24+00:00Added an answer on May 21, 2026 at 5:27 pm

    In terms of speed, it’s no competition for empty lists/dicts:

    >>> from timeit import timeit
    >>> timeit("[]")
    0.040084982867934334
    >>> timeit("list()")
    0.17704233359267718
    >>> timeit("{}")
    0.033620194745424214
    >>> timeit("dict()")
    0.1821558326547077
    

    and for non-empty:

    >>> timeit("[1,2,3]")
    0.24316302770330367
    >>> timeit("list((1,2,3))")
    0.44744206316727286
    >>> timeit("list(foo)", setup="foo=(1,2,3)")
    0.446036018543964
    >>> timeit("{'a':1, 'b':2, 'c':3}")
    0.20868602015059423
    >>> timeit("dict(a=1, b=2, c=3)")
    0.47635635255323905
    >>> timeit("dict(bar)", setup="bar=[('a', 1), ('b', 2), ('c', 3)]")
    0.9028228448029267
    

    Also, using the bracket notation lets you use list and dictionary comprehensions, which may be reason enough.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand that they are both supposed to be small, but what are the
I understand they both don't change the URL that the client sees. Is there
I understand that both JW player and Flow player are OS, but they both
I understand that requests are served by different threads, but do they all come
I'm reading up about attributes and understand that they can be made to apply
I'm having some trouble understanding the delegate/data source methodology. I understand that they exist
What are the differences between UTF-8, UTF-16, and UTF-32? I understand that they will
I'm really beginning to understand what people mean when they say that C++'s error
I understand that there are several ways to blend XNA and WPF within the
I'm a bit confused in how functions operate in javascript. I understand that they're

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.