正在加载视频...

视频加载失败

Can you solve this string comparison challenge? Explore the behavior of Python's string handling and learn about memory optimization in the language.

27,711 次观看 • 1 年前 •via X (Twitter)

3 条评论

Google for Developers 的头像
Google for Developers1 年前

Here's a hint:

Arman 的头像
Arman1 年前

print(a is d) will be False. While a is an interned string literal, "".join() creates a new string object for d, so they aren't the exact same object in memory, even if their value is identical.

1st Amendment 的头像
1st Amendment1 年前

you getting system responses from the ai too?

相关视频

String Theory Lecture 1 A String Does Not Move Like a Point A point particle traces a line through spacetime. A string traces a surface. This is the first geometric shift in String Theory. Particle mechanics asks where one object is at time t, so its history is a curve. String Theory asks where every point of an extended object is at worldsheet time τ, so we need another coordinate telling us where we are along the string. For a point particle x(t) So, for one input of time we get a position in Spacetime. For a string Xᵘ(τ,σ) Here τ plays the role of time on the worldsheet, while σ labels position along the string. Freeze τ and vary σ, and you see the string at one instant. Let τ move, and that curve sweeps out a two-dimensional surface... the worldsheet. The same comparison appears in the action. For a relativistic point particle, the geometric action measures worldline length S = −m ∫ ds If we parameterize the path by t, the action has one integral, one parameter, and one tangent vector dxᵘ/dt For a string, the same idea grows by one dimension. The action measures area, not length. In Nambu-Goto form, S = −T ∫ dτ dσ √[−det hₐᵦ] Here T is the string tension. It plays a role similar to mass, but for an extended object. It weights the area of a surface rather than the length of a line. The particle action has ∫ dt because the history is one-dimensional. The string action has ∫ dτ dσ because the history is two-dimensional. We are no longer summing along a path, we are summing over a surface. The geometry changes for the same reason. For the particle, one derivative is enough dxᵘ/dt For the string, the geometry is built from two derivatives: ∂τXᵘ and ∂σXᵘ The first tells you how the string changes as worldsheet time flows. The second tells you how the embedding changes as you move along the string. Together they define the induced worldsheet metric hₐᵦ = ∂ₐXᵘ ∂ᵦXᵤ In plain terms, hₐᵦ measures tangent lengths and tangent angles on the worldsheet. From it, the area element is dA = dτ dσ √[−det hₐᵦ] This, the Nambu-Goto action is the direct analogue of the point-particle length action. The point particle extremizes length and the string extremizes area. For calculations, people usually switch to the Polyakov action: S = −(T/2) ∫ dτ dσ √[−γ] γᵃᵇ ∂ₐXᵘ ∂ᵦXᵤ This describes the same classical string dynamics, but the algebra is cleaner. After choosing conformal gauge, varying with respect to Xᵘ gives (∂²/∂τ² − ∂²/∂σ²) Xᵘ = 0 This is the first real dynamical payoff... a two-dimensional wave equation on the worldsheet. For a point particle, the equation of motion tells you how one position evolves along one path. For a string, it tells you how an entire curve evolves, with waves traveling along it. The term ∂²Xᵘ/∂τ² measures acceleration in worldsheet time, while ∂²Xᵘ/∂σ² measures curvature along the string. The time evolution is balanced by how the string bends along its own length. This is why strings have oscillation modes. A point particle has one trajectory. A string has many possible vibration patterns, each one a normal mode of the worldsheet wave equation. For a closed string, σ wraps around the loop Xᵘ(τ, σ + 2π) = Xᵘ(τ, σ) For an open string, one standard free-end condition is ∂σXᵘ = 0 at the endpoints. Solving the wave equation gives waves moving in opposite directions along the string Xᵘ(τ,σ) = Fᵘ(τ + σ) + Gᵘ(τ − σ) A function of τ + σ moves one way. A function of τ − σ moves the other. Therefore, a particle has a worldline, its action measures length, and its geometry uses one tangent. The string has a worldsheet, its action measures area, and its geometry uses two tangent directions. #StringTheory #TheoreticalPhysics #MathematicalPhysics #Physics #Spacetime

Mathelirium

31,560 次观看 • 1 个月前