[issue42408] passing memoryview slice to struct packing functions

2020-11-19 Thread Daniel Hrisca


New submission from Daniel Hrisca :

First I have to apologize if this was discussed before; I've searched the 
issues and googled the problem but I got nothing obvious.

I'm trying to pass a memoryview slice as argument to struct packing functions 
to avoid creating intermediate bytes objects

from struct import Struct
s = Struct('<2Q500s').pack_into
buffer = bytearray(7000)
data = bytes(300)
s(buffer, 0, 500, 500, memoryview(data)[4:])


and I get this error:
error: argument for 's' must be a bytes object

Why is it not possible to use memoryviews in this case? 

It is also strange for me that we can use a memoyview as the target buffer, so 
this works fine:

s(memoryview(buffer)[10:], 0, 500, 500, data[4:])

--
messages: 381413
nosy: danielhrisca
priority: normal
severity: normal
status: open
title: passing memoryview slice to struct packing functions

___
Python tracker 
<https://bugs.python.org/issue42408>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37205] time.perf_counter() is not system-wide on Windows, in disagreement with documentation

2020-11-13 Thread Daniel Hrisca


Daniel Hrisca  added the comment:

Under the hood perf_counter_ns already uses the two winapi calls (see 
https://github.com/python/cpython/blob/41761933c1c30bb6003b65eef1ba23a83db4eae4/Python/pytime.c#L970)
 just that it also sets up a static variable as a time origin which makes it 
process-wide instead of system-wide

--

___
Python tracker 
<https://bugs.python.org/issue37205>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37205] time.perf_counter() is not system-wide on Windows, in disagreement with documentation

2020-11-13 Thread Daniel Hrisca


Daniel Hrisca  added the comment:

That would be perfect and would help a lot with timings/synchronization across 
multiple processes.

Which Pyhton version will get this fix?

--

___
Python tracker 
<https://bugs.python.org/issue37205>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37205] time.perf_counter() is not system-wide on Windows, in disagreement with documentation

2020-11-13 Thread Daniel Hrisca


Daniel Hrisca  added the comment:

I'm actually surprised that this problem gets so little interest. It's probably 
so obscure that most people don't even realize it.

Why isn't it implemented using winapi calls for the windows platform?

I took inspiration from this SO thread 
https://stackoverflow.com/questions/56502111/should-time-perf-counter-be-consistent-across-processes-in-python-on-windows
 
and came up with this function for 64 bit Python (a few more lines would be 
needed for error checking)

#include 
static PyObject* perf_counter(PyObject* self, PyObject* args)
{
PyObject* ret;

QueryPerformanceFrequency(lpFrequency);
QueryPerformanceCounter(lpPerformanceCount);

ret = PyFloat_FromDouble(((double) lpPerformanceCount->QuadPart ) / 
lpFrequency->QuadPart);

return ret;
}

--
nosy: +danielhrisca

___
Python tracker 
<https://bugs.python.org/issue37205>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32319] re fullmatch error with non greedy modifier

2017-12-13 Thread Daniel Hrisca

New submission from Daniel Hrisca <daniel.hri...@gmail.com>:

Consider this code snippet:


from re import match, fullmatch

pattern = '".+?"'
string = '"hello" "again"'

print(match(pattern, string))
print(fullmatch(pattern, string))


Which prints:
<_sre.SRE_Match object; span=(0, 7), match='"hello"'>
<_sre.SRE_Match object; span=(0, 15), match='"hello" "again"'>

The fullmatch function seems to ignore the non-greedy modifier.

>From the fullmatch docstring I expected that fullmatch is equivalent to:

def fullmatch(pattern, string):
match = re.match(pattern, string)
if match:
if match.start() == 0 and match.end() == len(string):
return match
else:
return None
else:
return None

--
components: Library (Lib)
messages: 308278
nosy: danielhrisca
priority: normal
severity: normal
status: open
title: re fullmatch error with non greedy modifier
type: behavior
versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32319>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com