Re: Can't do a multiline assignment!



On Apr 17, 6:02 pm, s0s...@xxxxxxxxx wrote:
[...]
I do it with all the separate variables mainly for performance. If I
had the headers in a dict, I'd be looking up a string in a list of
strings (the keys of the dict) everytime I check for a header. Not
that that's going to take more that 0.1 seconds, but the program is
still small and simple. As it gets bigger, more features are gonna
slow things down.

- Have you measured the difference in performance?

- Are you aware that attribute access is implemented as string lookup
in a dictionary?

i.e. when you write foo.bar, the interpreter looks for 'bar' in
foo.__dict__, and if it doesn't find it, then proceeds to look in
type(foo).__dict__. So in your code, if a header (with manager rhm)
has no 'allow' field and you do:

rhm.Allow

the interpreter looks up *two* dictionaries (rhm.__dict__ then
RequestHeadersManager.__dict__).

--
Arnaud


--
Arnaud

.



Relevant Pages

  • Re: Help With PyParsing of output from win32pdhutil.ShowAllProcesses()
    ... None to a string). ... Still have an urge to parse with pyparsing? ... pyparsing Dict class. ... keys from the parsed data, so it looks like you are already thinking ...
    (comp.lang.python)
  • Re: Hungarian Notation
    ... string called headers, but I want to derive a dict from it, also called ... So I figured the string would be called strHeaders, and the dict, ... since they don't agree with the naming conventions in PEP 8. ...
    (comp.lang.python)
  • Re: Cant do a multiline assignment!
    ... strings (the keys of the dict) everytime I check for a header. ... dictionaries are optimized to be fast. ... (the string) ... Thus putting your headers in a ...
    (comp.lang.python)
  • Re: Can anyone tell me of any optimations I could do to this to make it faster?
    ... the tables that it grabs the headers from is temporary. ... the string class to do this. ... public string subject; ... static void Main ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Blank emails
    ... The issue I was relating comes about because Lotus Notes uses a space ... wraps the string at the space in the message header. ... The message source is always readable no matter how mangled the ... corrupts MIME headers of messages from Lotus Notes, ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)