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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:05:14+00:00 2026-06-15T04:05:14+00:00

Is sequence unpacking atomic? e.g.: (a, b) = (c, d) I’m under the impression

  • 0

Is sequence unpacking atomic? e.g.:

(a, b) = (c, d)

I’m under the impression it is not.

Edit: I meant atomicity in the context of multi-threading, i.e. whether the entire statement is indivisible, as atoms used to be.

  • 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-06-15T04:05:16+00:00Added an answer on June 15, 2026 at 4:05 am

    It is one operation; the right-hand expression is evaluated before the left-hand assignment is applied:

    >>> a, b = 10, 20
    >>> a, b
    (10, 20)
    >>> b, a = a, b
    >>> a, b
    (20, 10)
    >>> a, b = a*b, a/b
    >>> a, b
    (200, 2)
    

    Or, if you are talking about multi-threaded environments, then the assignment is not atomic; the interpreter evaluates a tuple assignment with a single opcode, but uses separate opcodes to then store the results into each affected variable:

    >>> def t(self): a,b=20,20
    ... 
    >>> dis.dis(t)
      1           0 LOAD_CONST               2 ((20, 20))
                  3 UNPACK_SEQUENCE          2
                  6 STORE_FAST               1 (a)
                  9 STORE_FAST               2 (b)
                 12 LOAD_CONST               0 (None)
                 15 RETURN_VALUE        
    

    However, normal assigment is always going to be at least two opcodes (one for the right-hand expression, one for storing the result), so in python in general assigment is not atomic. Sequence unpacking is no different.

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

Sidebar

Related Questions

This sequence satisfies a(n+2) = 2 a(n+1) + 2 a(n). and also a(n)=[(1+sqrt(3))^(n+2)-(1-sqrt(3))^(n+2)]/(4sqrt(3)). I
Given sequence : [1,A,B,C,2,F,K,L,5,6,P,I,E] The numbers represent items that I identify as headers, whereas
A sequence point in imperative programming defines any point in a computer program's execution
I have a sequence which varies in length e.g. something like: items <- 1:4
In UML sequence diagram a method can have only one return line (at least
Ruby compacts the sequence only if it has nil value, how do I compact
I have a sequence like [0, 1, 0, 1, 0, 1, 0] and I
I am using thrust::sequence(myvector.begin(), myvector.end(), 0, 1) and achieve good ordered list like: 0,
Given the following sequence diagram, how to express the equivalent in a UML communication
I have a sequence of maps. ;; input [{:country MX, :video 12345, :customer cid1}

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.