Re: how to fast processing one million strings to remove quotes

2017-08-03 Thread Peter Otten
Tim Daneliuk wrote: > On 08/02/2017 10:05 AM, Daiyue Weng wrote: >> Hi, I am trying to removing extra quotes from a large set of strings (a >> list of strings), so for each original string, it looks like, >> >> """str_value1"",""str_value2"",""str_value3"",1,""str_value4""" >> >> >> I like to r

Re: how to fast processing one million strings to remove quotes

2017-08-03 Thread Nick Mellor
Sorry Daiyue, Try this correction: I'm writing code without being able to execute it. > split_on_dbl_dbl_quote = original_list.join('|').split('""') > remove_dbl_dbl_quotes_and_outer_quotes = > split_on_dbl_dbl_quote[::2].join('').split('|') split_on_dbl_dbl_quote = original_list.join('|').sp

Re: how to fast processing one million strings to remove quotes

2017-08-03 Thread Tim Daneliuk
On 08/02/2017 10:05 AM, Daiyue Weng wrote: > Hi, I am trying to removing extra quotes from a large set of strings (a > list of strings), so for each original string, it looks like, > > """str_value1"",""str_value2"",""str_value3"",1,""str_value4""" > > > I like to remove the start and end quotes

SSL/TLS support in Pyro4

2017-08-03 Thread Irmen de Jong
Hi, Pyro4 (http://pyro4.readthedocs.io) allows you to call methods on Python objects running on other machines, as if they were just normal local objects. Regarding the network communication: it hasn't got any real security mechanisms built-in and always explicitly depended on external tools or

Re: @lru_cache on functions with no arguments

2017-08-03 Thread Ian Kelly
On Thu, Aug 3, 2017 at 12:17 PM, Ian Kelly wrote: > On Thu, Aug 3, 2017 at 11:18 AM, Serhiy Storchaka wrote: >> $ ./python -m timeit -s 'import sys; sys.modules["_functools"] = None; del >> sys.modules["functools"]; from functools import lru_cache; f = >> lru_cache(maxsize=None)(int)' -- 'f()' >>

Re: @lru_cache on functions with no arguments

2017-08-03 Thread Ian Kelly
On Thu, Aug 3, 2017 at 11:18 AM, Serhiy Storchaka wrote: > $ ./python -m timeit -s 'import sys; sys.modules["_functools"] = None; del > sys.modules["functools"]; from functools import lru_cache; f = > lru_cache(maxsize=None)(int)' -- 'f()' > 10 loops, best of 5: 3.39 usec per loop Interesting

Re: @lru_cache on functions with no arguments

2017-08-03 Thread Serhiy Storchaka
03.08.17 19:08, Ian Kelly пише: This turns out to be because I was running 3.4 which doesn't have the C implementation to begin with. In 3.6 this trick doesn't seem to work as expected for disabling it: It didn't work because the functools module already was imported at startup. $ ./python -m

Re: @lru_cache on functions with no arguments

2017-08-03 Thread Ian Kelly
On Thu, Aug 3, 2017 at 10:02 AM, Ian Kelly wrote: > Fixed: > > $ python3 -m timeit -s 'from simple_cache import simple_cache; f = > simple_cache(int)' -- 'f()' > 100 loops, best of 3: 0.167 usec per loop > $ python3 -m timeit -s 'import sys; sys.modules["_functools"] = None; > from functools i

Re: @lru_cache on functions with no arguments

2017-08-03 Thread Ian Kelly
On Thu, Aug 3, 2017 at 9:55 AM, Serhiy Storchaka wrote: > 03.08.17 18:36, Ian Kelly пише: >> >> The single variable is only a dict lookup if it's a global. Locals and >> closures are faster. >> >> def simple_cache(function): >> sentinel = object() >> cached = sentinel >> >> @functoo

Re: @lru_cache on functions with no arguments

2017-08-03 Thread Ian Kelly
On Thu, Aug 3, 2017 at 9:44 AM, wrote: > I hope you washed them! Yes, well as noted in my followup I was comparing pure-Python implementations, not the C implementation. -- https://mail.python.org/mailman/listinfo/python-list

Re: @lru_cache on functions with no arguments

2017-08-03 Thread Serhiy Storchaka
03.08.17 18:36, Ian Kelly пише: The single variable is only a dict lookup if it's a global. Locals and closures are faster. def simple_cache(function): sentinel = object() cached = sentinel @functools.wraps(function) def wrapper(*args, **kwargs): nonlocal cached

Re: @lru_cache on functions with no arguments

2017-08-03 Thread tom
On Thursday, 3 August 2017 16:37:22 UTC+1, Ian wrote: > On Thu, Aug 3, 2017 at 8:35 AM, Paul Moore ...@gmail.com> wrote: > > On Tuesday, 1 August 2017 15:54:42 UTC+1, t...@tomforb.es wrote: > >> > _sentinel = object() > >> > _val = _sentinel > >> > def val(): > >> > if _val is _sentinel: > >

Re: @lru_cache on functions with no arguments

2017-08-03 Thread Ian Kelly
On Thu, Aug 3, 2017 at 9:36 AM, Ian Kelly wrote: > On Thu, Aug 3, 2017 at 8:35 AM, Paul Moore wrote: >> On Tuesday, 1 August 2017 15:54:42 UTC+1, t...@tomforb.es wrote: >>> > _sentinel = object() >>> > _val = _sentinel >>> > def val(): >>> > if _val is _sentinel: >>> > # Calculate _

Re: @lru_cache on functions with no arguments

2017-08-03 Thread Ian Kelly
On Thu, Aug 3, 2017 at 8:35 AM, Paul Moore wrote: > On Tuesday, 1 August 2017 15:54:42 UTC+1, t...@tomforb.es wrote: >> > _sentinel = object() >> > _val = _sentinel >> > def val(): >> > if _val is _sentinel: >> > # Calculate _val >> > return _val >> > >> > seems entirely sufficie

Re: @lru_cache on functions with no arguments

2017-08-03 Thread Paul Moore
On Tuesday, 1 August 2017 15:54:42 UTC+1, t...@tomforb.es wrote: > > _sentinel = object() > > _val = _sentinel > > def val(): > > if _val is _sentinel: > > # Calculate _val > > return _val > > > > seems entirely sufficient for this case. Write a custom decorator if you > > use th

Re: python in chromebook

2017-08-03 Thread Byung-Hee HWANG (황병희, 黃炳熙)
attend 께서 쓰시길, 《記事 全文 에서》: > On Thu, 27 Jul 2017 10:03:29 +0900, Byung-Hee HWANG (황병희, 黃炳熙) wrote: > >> my computer is chromebook. how can i install python in chromebook? >> barely i did meet develop mode of chromebook. also i'm new to python. >> >> INDEED, i want to make python code on my chr

Re: how to fast processing one million strings to remove quotes

2017-08-03 Thread Thomas Jollans
On 2017-08-02 19:05, MRAB wrote: > On 2017-08-02 16:05, Daiyue Weng wrote: >> Hi, I am trying to removing extra quotes from a large set of strings (a >> list of strings), so for each original string, it looks like, >> >> """str_value1"",""str_value2"",""str_value3"",1,""str_value4""" >> >> >> I lik

Re: how to sort a list of tuples with custom function

2017-08-03 Thread Ho Yeung Lee
I remove red line and capture another version https://gist.github.com/hoyeunglee/99bbe7999bc489a79ffdf0277e80ecb6 it can capture words in windows, but since window words some are black and some gray, some are not exactly black, so I only choose notepad , since it is using black words but some

coroutines

2017-08-03 Thread ast
Hello Here a code for a simple demultiplexer coroutine def demultiplexer(target1, target2): while True: data = yield target1.send(data) target2.send(data) When data is sent to target1, what Cpython do immediately after ? 1- Go on execute demultiplexer, so send a dat

Re: how to sort a list of tuples with custom function

2017-08-03 Thread Ho Yeung Lee
https://gist.github.com/hoyeunglee/3d340ab4e9a3e2b7ad7307322055b550 I updated again how to do better because some words are stored in different files On Thursday, August 3, 2017 at 10:02:01 AM UTC+8, Ho Yeung Lee wrote: > https://gist.github.com/hoyeunglee/f371f66d55f90dda043f7e7fea38ffa2 > > I

Re: cgiapp versus apache & nginx+fcgiwrap

2017-08-03 Thread Robin Becker
On 02/08/2017 20:34, Glenn Linderman wrote: On 8/2/2017 1:13 AM, Robin Becker wrote: we always seem to get keys in K even if it is an empty list. Can you treat None and empty list the same? Looking at the envirnment that the cgi script sees I cannot see anything obvious except the expecte