From f017218b64b46bfb850bac4f8664c11c71379936 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Mon, 21 Jan 2013 08:54:19 -0500 Subject: [PATCH] Uses class constants for message text instead of ndict. Reducing use of ndict on the path to fixing a memory leak. So that pulling an instance of ndict with objgraph is more likely to be a use of ndict that is causing the leak. Using a class level constant here suffices for the dot access desired on messages. --- zipline/MESSAGES.py | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/zipline/MESSAGES.py b/zipline/MESSAGES.py index 1a189cfc..2c67395b 100644 --- a/zipline/MESSAGES.py +++ b/zipline/MESSAGES.py @@ -1,37 +1,40 @@ -from zipline import ndict + + # --------------------- # Error Messages. # User facing. # --------------------- -ERRORS = ndict({ +class ERRORS(object): # Raised if a user script calls the override_slippage magic # with a slipage object that isn't a VolumeShareSlippage or # FixedSlipapge - 'UNSUPPORTED_SLIPPAGE_MODEL': - "You attempted to override slippage with an unsupported class. \ - Please use VolumeShareSlippage or FixedSlippage.", + UNSUPPORTED_SLIPPAGE_MODEL = """ +You attempted to override slippage with an unsupported class. \ +Please use VolumeShareSlippage or FixedSlippage. +""".strip() # Raised if a users script calls override_slippage magic # after the initialize method has returned. - 'OVERRIDE_SLIPPAGE_POST_INIT': - "You attempted to override slippage after the simulation has \ - started. You may only call override_slippage in your initialize \ - method.", + OVERRIDE_SLIPPAGE_POST_INIT = """ +You attempted to override slippage after the simulation has \ +started. You may only call override_slippage in your initialize \ +method. +""".strip() # Raised if a user script calls the override_commission magic # with a commission object that isn't a PerShare or # PerTrade commission - 'UNSUPPORTED_COMMISSION_MODEL': - "You attempted to override commission with an unsupported class. \ - Please use PerShare or PerTrade.", + UNSUPPORTED_COMMISSION_MODEL = """ +You attempted to override commission with an unsupported class. \ +Please use PerShare or PerTrade. +""".strip() # Raised if a users script calls override_commission magic # after the initialize method has returned. - 'OVERRIDE_COMMISSION_POST_INIT': - "You attempted to override commission after the simulation has \ - started. You may only call override_commission in your initialize \ - method.", - -}) + OVERRIDE_COMMISSION_POST_INIT = """ +You attempted to override commission after the simulation has \ +started. You may only call override_commission in your initialize \ +method. +""".strip()