New submission from Cezary Wagner :
I am experienced programmer 10y+ - that is very very strange performance
problem when I play Python timeit with my son :)
three way operator a <= x <= b is slower than a <= x and x <= b.
It looks like wrong implementation since it is impossi
Cezary Wagner added the comment:
Some more experiments:
import dis
import timeit
REPEATS = 100
def test1():
selected = []
for i in range(REPEATS):
if i >= 25 and i <= 75:
selected.append(i)
return selected
def test2():
selected = []
for i in
New submission from Cezary Wagner :
I wrote code which scan very large file PGN (chess games database).
But I found that tell() function is buggy see results.
Here is some code:
with open('../s01_parser_eval/data/out-6976.txt') as pgn:
is_game_parsed = parser.
Cezary Wagner added the comment:
Some good snippet for testing very short.
with open('../s01_parser_eval/data/out-6976.txt') as pgn:
pgn.seek(1008915299)
while True:
pgn.readline()
print(pgn.tell())
1008915327
1008915366
1008915387
1008915409
1008915425
Change by Cezary Wagner :
--
title: Wrong tell function results. -> Wrong tell function results (Windows
10/Python 64 3.8.2)
___
Python tracker
<https://bugs.python.org/issu
Cezary Wagner added the comment:
I do some test and bu exist in 3.8/3.7 but not in no bug in PyPy3.6/Python2.7.
--
title: Wrong file.tell() function results (Windows 10/Python 64 3.8.2/3.7 - no
bug in PyPy2.6/Python2.7) -> Wrong file.tell() function results (Windows
10/Python
Change by Cezary Wagner :
--
title: Wrong tell function results (Windows 10/Python 64 3.8.2) -> Wrong
file.tell() function results (Windows 10/Python 64 3.8.2/3.7 - no bug in
PyPy2.6/Python2.7)
___
Python tracker
<https://bugs.pyth
Change by Cezary Wagner :
--
components: +IO, Interpreter Core, Windows
nosy: +paul.moore, steve.dower, tim.golden, zach.ware
versions: +Python 3.7
___
Python tracker
<https://bugs.python.org/issue39
Cezary Wagner added the comment:
Let's test it now.
--
___
Python tracker
<https://bugs.python.org/issue39962>
___
___
Python-bugs-list mailing list
Cezary Wagner added the comment:
Really really strange but it works :)
"an opaque number when in text mode." -> so it is Windows C libraries.
I use it in production code too so my heart speed up when I see number but it
works as you said.
It looks complicated/slow if I have to
Cezary Wagner added the comment:
Thank you for very good explanation. It was hard to understand.
I am programming a lot (++10 years) in many language but I still learning new
things.
--
___
Python tracker
<https://bugs.python.org/issue39
Cezary Wagner added the comment:
> The I/O stack in Python 3 does not use C FILE streams, and this issue is not
> related to Windows. TextIOWrapper.tell returns a "cookie" based on the
> decoder state:
That can big problem when I use serialization if f.tell() is "co
Cezary Wagner added the comment:
I tested is and it is not "state cookie" but it is "absolute position" and it
is "stateless".
> The I/O stack in Python 3 does not use C FILE streams, and this issue is not
> related to Windows. TextIOWrapper.tell return
Cezary Wagner added the comment:
C:\root\Python\Python38\python.exe "C:/Users/Cezary
Wagner/PycharmProjects/chess-lichess-eval-parse/sandbox/s03_create_tree/s03_python_bug.py"
seek 18446744073709554618
3003
seek 0
75
114
145
165
181
205
227
246
265
290
315
328
365
3
New submission from Cezary Wagner :
I have problem with change detection of log during writing under Windows
(normal fs and windows share). Probably bad order of Windows API calls - no
idea.
Test program is attached. You can reproduce it. Try with os.scandir() without
os.stats() and os.stat
Cezary Wagner added the comment:
Extra file for for tests with:
DO_STAT = False
See not changes but file was writing every second. If os.stat() run all between
call os.scandir() all works.
C:\root\Python38\python.exe
C:/Users/Cezary.Wagner/PycharmProjects/dptr-monitoring-v2/sandbox/python
Cezary Wagner added the comment:
One hint more.
Start of new process os.scandir() give invalid modification date for file open
for writing until external tool is not called (like explorer, touch, etc.).
So (log open for writing and write is done between 1, 2):
1. Run program with os.scandir
Cezary Wagner added the comment:
I do some test on linux all works - changes are detected and os.scandir() works
but in Windows not - probably there is not unit test which check if
os.scandir() is working on open files for writing.
f.flush() no matter since file can be changed in external
Cezary Wagner added the comment:
Use case - detection of changes in open files is very important - log scanning
- synchronization ...
I think that first of all it is need good unit test to detect this problem
(rare edge case - probably it is missed because hard to imagine that it can not
Cezary Wagner added the comment:
I read some comments os.flush() or os.fsync() can be unrelated to problem.
External application can be written in C# or whatever you want.
Under Windows (not Linux) - modification dates will be stalled in such sequence.
os.scandir()
dir_entry.stat() # let it
Cezary Wagner added the comment:
I think we can assume that NTFS is priority since that is the most used option.
I can not discuss what with FAT32 or FAT since I am not the best in this domain
(in NTFS I am not the best too now). Whatever I think that system must do
allocation for open
Cezary Wagner added the comment:
As far as I know os.stat() resets d.stat() maybe should be added some option to
d.stat() to force update(). d.stat(nt_force_update=True).
I am not sure if os.path.getmtime() can reset d.stat().
os.stat() is 2x times slower than os.path.getmtime() and
Cezary Wagner added the comment:
Stockfish works like that:
1. Run command line and listen stdout.
2. Send some stdin and listen stdin.
3. stdout is asynchronous and continous (there no single output, line is
generated every some time).
I want to send some stdin than listen stdout response
Cezary Wagner added the comment:
See new code example (little changed):
It block after first stdout:
import asyncio
import sys
async def run_stockfish():
STOCKFISH_PATH = r'C:\root\chess\stockfish\stockfish
10\stockfish_10_x64_bmi2.exe'
stockfi
Cezary Wagner added the comment:
Another code try - this time I am using task:
import asyncio
import sys
async def process_line_reader(process, on_line=None, on_eof=None):
while not process.stdout.at_eof():
# BUG? after first line it becomes dead
line = await
Cezary Wagner added the comment:
It just tested it today and I found in parallel same solution as you suggested.
Sometimes it happen even your skilled programmer - at least one time in year :)
I was just blind. Let's close it since it is invalid report.
I just skipped new line at e
New submission from Cezary Wagner :
I have some problems with asyncio on Windows - it block where it should go.
Documentation shows that it should work:
https://docs.python.org/3/library/asyncio-stream.html -> StreamReader should
return something.
See 1st example:
import asyncio
import
Cezary Wagner added the comment:
It looks like StremReader.read() not work and StremReader.readline() in Windows
or I am not understand documentation.
https://docs.python.org/3/library/asyncio-stream.html
coroutine read(n=-1)
Read up to n bytes. If n is not provided, or set to -1, read
Cezary Wagner added the comment:
I am fighting with multiprocessing and still not won - I need to invent new
Python coding style to use it and can not reduce ugly code/microcoding. It is
not because it is not possible to do it in Python easier but because it is not
improved yet
Changes by Cezary Wagner :
--
versions: +Python 2.7
___
Python tracker
<http://bugs.python.org/issue23514>
___
___
Python-bugs-list mailing list
Unsubscribe:
Cezary Wagner added the comment:
Yes it is what is wanted by me and other people I think.
1. enter has not start call.
2. exit has shutdown but it is not supported
3. 'with' is what is need since it is simple to manage
Good analysis.
--
Cezary Wagner added the comment:
Should I add this suggestion to open before issue?
I started doing multiprocessing code in Python so I can have more suggestions
since I found that documentation can be improved I will report specific problem
32 matches
Mail list logo