Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #100134

Re: Understanding Python from a PHP coder's perspective

From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: Understanding Python from a PHP coder's perspective
Date 2015-12-08 14:47 +1100
Message-ID <mailman.49.1449546462.12405.python-list@python.org> (permalink)
References (1 earlier) <44d92f52-4f92-470d-a724-102a14d185de@googlegroups.com> <mailman.35.1449525620.12405.python-list@python.org> <3e30fc58-4460-40a6-a639-22cd4d406f0b@googlegroups.com> <CAPTjJmoG2BSc_vWpKaKjBPfGCHXRgboYPdq-BnA5rCkmrZa0YA@mail.gmail.com> <20151207211114.49a82ef3@bigbox.christie.dr>

Show all headers | View raw


On Tue, Dec 8, 2015 at 2:11 PM, Tim Chase <python.list@tim.thechases.com> wrote:
> On 2015-12-08 10:09, Chris Angelico wrote:
>> All three are very different.
>>
>> 1) Process state.
>>
>> You start up a Python program, and it sits there waiting for a
>> request. You give it a request, and get back a response; it goes
>> back to waiting for a request. If you change a global variable, or
>> maintain persistent state, or anything, the next request will 'see'
>> that change. This is completely global.
>
> 1) This is completely global *to the process* (you can have multiple
> Python processes sitting around waiting, taking advantage of multiple
> cores)
>
> 2) This is almost always a bad idea for multiple reasons (it can get
> in the way of scaling, it can produce hard-to-track-down bugs, etc).
> Use a real session store (a database, a key/value store like
> memcached, a NoSQL store like Redis, store session info in cookies,
> etc.) instead.

If your goal is session state, then yes - use something that actually
persists past the process life. But for caches and stuff, where
dropping them has performance implications but nothing else, it makes
good sense to keep them in globals. Particularly if you simply
populate the cache on process load and then never lose it.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Understanding Python from a PHP coder's perspective villascape@gmail.com - 2015-12-07 13:07 -0800
  Re: Understanding Python from a PHP coder's perspective villascape@gmail.com - 2015-12-07 13:21 -0800
    Re: Understanding Python from a PHP coder's perspective Chris Angelico <rosuav@gmail.com> - 2015-12-08 09:00 +1100
      Re: Understanding Python from a PHP coder's perspective villascape@gmail.com - 2015-12-07 14:27 -0800
        Re: Understanding Python from a PHP coder's perspective Chris Angelico <rosuav@gmail.com> - 2015-12-08 10:09 +1100
          Re: Understanding Python from a PHP coder's perspective villascape@gmail.com - 2015-12-07 17:00 -0800
            Re: Understanding Python from a PHP coder's perspective Chris Angelico <rosuav@gmail.com> - 2015-12-08 14:26 +1100
        Re: Understanding Python from a PHP coder's perspective Ian Kelly <ian.g.kelly@gmail.com> - 2015-12-07 16:10 -0700
        Re: Understanding Python from a PHP coder's perspective Cameron Simpson <cs@zip.com.au> - 2015-12-08 10:07 +1100
        Re: Understanding Python from a PHP coder's perspective Tim Chase <python.list@tim.thechases.com> - 2015-12-07 21:11 -0600
        Re: Understanding Python from a PHP coder's perspective Chris Angelico <rosuav@gmail.com> - 2015-12-08 14:47 +1100
  Re: Understanding Python from a PHP coder's perspective Cameron Simpson <cs@zip.com.au> - 2015-12-08 08:33 +1100
  Re: Understanding Python from a PHP coder's perspective Ian Kelly <ian.g.kelly@gmail.com> - 2015-12-07 14:37 -0700
  Re: Understanding Python from a PHP coder's perspective Chris Angelico <rosuav@gmail.com> - 2015-12-08 08:40 +1100
  Re: Understanding Python from a PHP coder's perspective Terry Reedy <tjreedy@udel.edu> - 2015-12-07 16:53 -0500
  Re: Understanding Python from a PHP coder's perspective Ian Kelly <ian.g.kelly@gmail.com> - 2015-12-07 14:59 -0700
  Re: Understanding Python from a PHP coder's perspective Chris Angelico <rosuav@gmail.com> - 2015-12-08 09:03 +1100
  Re: Understanding Python from a PHP coder's perspective Tim Chase <python.list@tim.thechases.com> - 2015-12-07 16:28 -0600
  Re: Understanding Python from a PHP coder's perspective villascape@gmail.com - 2015-12-07 20:11 -0800
  Re: Understanding Python from a PHP coder's perspective Peter Otten <__peter__@web.de> - 2015-12-08 10:24 +0100
  Re: Understanding Python from a PHP coder's perspective Chris Angelico <rosuav@gmail.com> - 2015-12-08 20:40 +1100

csiph-web