Merge lp:~jtv/launchpad/bug-455467 into lp:launchpad

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Aaron Bentley
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~jtv/launchpad/bug-455467
Merge into: lp:launchpad
Diff against target: 15 lines
1 file modified
lib/lp/translations/scripts/message_sharing_migration.py (+3/-1)
To merge this branch: bzr merge lp:~jtv/launchpad/bug-455467
Reviewer Review Type Date Requested Status
Aaron Bentley (community) Approve
Review via email: mp+13570@code.launchpad.net

Commit message

Memory savings for message-sharing migration.

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

= Bug 455467 =

Very simple memory-saver for the message-sharing migration script, which
is too memory-intensive for the larger projects and packages. Since the
messages' msgids aren't used except for identifying different messages,
and each message is stored in the database exactly once with a unique
row id, all this script really needs to see is their foreign keys.

Since this was neatly isolated in a function, there is only one code
change and no tests are affected. Run "bin/test -t message.sharing" to
verify.

Jeroen

Revision history for this message
Aaron Bentley (abentley) wrote :

AFAICT, this is changing the return type of the function, and not updating any of the callsites. Why is that okay?

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

The return type is only ever used for one thing: finding cases where two potmsgsets are "identical" (as far as the given properties are concerned). All that's needed is that the return values for two potmsgsets be comparable. Even the ordering is arbitrary, as long as a dict will see the keys from two identical potmsgsets as equal and the keys from two non-identical potmsgsets as unequal. The values inside the key are never unpacked.

In my cover letter, the bit about unique row ids was an attempt to show why this transformation preserves the desired comparison properties.

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

The best thing to say always comes to one when it's too late.

The short answer is "duck typing." :-)

Revision history for this message
Aaron Bentley (abentley) wrote :

"Duck typing" wouldn't have helped in this case; understanding that the return values were only compared with each other was key for me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/scripts/message_sharing_migration.py'
2--- lib/lp/translations/scripts/message_sharing_migration.py 2009-08-12 05:00:48 +0000
3+++ lib/lp/translations/scripts/message_sharing_migration.py 2009-10-19 14:40:34 +0000
4@@ -25,8 +25,10 @@
5 A POTMsgSet is identified by its msgid, optional plural msgid, and
6 optional context identifier.
7 """
8+ potmsgset = removeSecurityProxy(potmsgset)
9 return (
10- potmsgset.msgid_singular, potmsgset.msgid_plural, potmsgset.context)
11+ potmsgset.msgid_singularID, potmsgset.msgid_pluralID,
12+ potmsgset.context)
13
14
15 def merge_pofiletranslators(from_potmsgset, to_template):