Skip to main content
deleted 4 characters in body
Source Link
the Tin Man
  • 160.1k
  • 44
  • 218
  • 306

Carl, inIn a follow-up answer, you asked about the relative performance of these two alternatives:

Example 1: identical dictionaries mapping 20 consecutive integers to themselves:

Example 2: non-overlapping dictionaries mapping 252 short strings to integers and vice versa:

Carl, in a follow-up answer, you asked about the relative performance of these two alternatives:

Example 1: identical dictionaries mapping 20 consecutive integers to themselves

Example 2: non-overlapping dictionaries mapping 252 short strings to integers and vice versa

In a follow-up answer, you asked about the relative performance of these two alternatives:

Example 1: identical dictionaries mapping 20 consecutive integers to themselves:

Example 2: non-overlapping dictionaries mapping 252 short strings to integers and vice versa:

[UPDATE: You could also write this as

as Tony does, but (not surprisingly) the difference in notation turns out not to have any measurable effect on performance. Use whichever looks right to you. Of course, he's absolutely correct to point out that the two-statement version is much easier to understand.]

[UPDATE: You could also write this as

as Tony does, but (not surprisingly) the difference in notation turns out not to have any measurable effect on performance. Use whichever looks right to you. Of course, he's absolutely correct to point out that the two-statement version is much easier to understand.]

You could also write this as

as Tony does, but (not surprisingly) the difference in notation turns out not to have any measurable effect on performance. Use whichever looks right to you. Of course, he's absolutely correct to point out that the two-statement version is much easier to understand.

addressed x.copy() vs dict(x)
Source Link
zaphod
  • 4.6k
  • 3
  • 26
  • 26

[UPDATE: You could also write this as

z0 = x.copy()
z0.update(y)

as Tony does, but (not surprisingly) the difference in notation turns out not to have any measurable effect on performance. Use whichever looks right to you. Of course, he's absolutely correct to point out that the two-statement version is much easier to understand.]

[UPDATE: You could also write this as

z0 = x.copy()
z0.update(y)

as Tony does, but (not surprisingly) the difference in notation turns out not to have any measurable effect on performance. Use whichever looks right to you. Of course, he's absolutely correct to point out that the two-statement version is much easier to understand.]

Source Link
zaphod
  • 4.6k
  • 3
  • 26
  • 26
Loading