[issue9051] Improve pickle format for timezone aware datetime instances

2017-03-06 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
resolution:  -> rejected
stage: patch review -> resolved
status: pending -> closed

___
Python tracker 

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



[issue9051] Improve pickle format for timezone aware datetime instances

2017-03-06 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
status: open -> pending

___
Python tracker 

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



[issue9051] Improve pickle format for timezone aware datetime instances

2015-11-16 Thread Roundup Robot

Roundup Robot added the comment:

New changeset e48da8f01316 by Serhiy Storchaka in branch '3.4':
Issue #9051: Added tests for pickling and copying the timezone objects.
https://hg.python.org/cpython/rev/e48da8f01316

New changeset 634905e9628d by Serhiy Storchaka in branch '3.5':
Issue #9051: Added tests for pickling and copying the timezone objects.
https://hg.python.org/cpython/rev/634905e9628d

New changeset 9c31544d6a66 by Serhiy Storchaka in branch 'default':
Issue #9051: Added tests for pickling and copying the timezone objects.
https://hg.python.org/cpython/rev/9c31544d6a66

--
nosy: +python-dev

___
Python tracker 

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



[issue9051] Improve pickle format for timezone aware datetime instances

2015-11-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

>>> import pickle, pickletools, datetime
>>> len(pickle.dumps([datetime.datetime.utcfromtimestamp(i) for i in 
>>> range(1)], 3)) / 1
30.9283
>>> len(pickle.dumps([datetime.datetime.fromtimestamp(i, datetime.timezone.utc) 
>>> for i in range(1)], 3)) / 1
32.936
>>> len(pickle.dumps([datetime.datetime.utcfromtimestamp(i) for i in 
>>> range(1)], 4)) / 1
19.0074
>>> len(pickle.dumps([datetime.datetime.fromtimestamp(i, datetime.timezone.utc) 
>>> for i in range(1)], 4)) / 1
21.0144

In best case the UTC timezone costs only 2 bytes per datetime instance (BINGET 
+ 1-byte index). In worst case it can cost 5 bytes (LONG_BINGET + 4-bytes 
index). Saving few bytes for single timezone instance has significant effect 
only for small pickled data. But in this case it is more advantageous to save a 
datetime just as a timestamp. I suggest to close this issue.

--

___
Python tracker 

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



[issue9051] Improve pickle format for timezone aware datetime instances

2015-10-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Following patch adds tests for timezone pickling and copying. Note, that 
timezone.utc identity is preserved.

--
stage: needs patch -> patch review
Added file: http://bugs.python.org/file40852/timezone_test_pickle.patch

___
Python tracker 

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



[issue9051] Improve pickle format for timezone aware datetime instances

2015-09-28 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
nosy: +tim.peters

___
Python tracker 

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



[issue9051] Improve pickle format for timezone aware datetime instances

2015-09-28 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

> there is a risk that the "_utc" variable can be renamed
> and this will break pickle compatibility.

I think we will still need to maintain _utc global indefinitely to keep the old 
pickles readable.

On the other hand, it looks like support for qualnames is only available with 
pickle protocol 4, so I don't see any downside from from storing the full 
qualname other than an 8-byte increase in the size of the pickle.

I guess my position on this will be +0:  I'll accept a patch if someone will 
submit it, but I am unlikely to do it myself.

--

___
Python tracker 

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



[issue9051] Improve pickle format for timezone aware datetime instances

2015-09-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> I think we will still need to maintain _utc global indefinitely to keep the 
> old pickles readable.

We have no need to maintain _utc global indefinitely if don't add it.

> On the other hand, it looks like support for qualnames is only available with 
> pickle protocol 4,

No, support for qualnames now is available with all pickle protocols.

--

___
Python tracker 

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



[issue9051] Improve pickle format for timezone aware datetime instances

2015-09-26 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

> For stability it is better to use public name 'timezone.utc' instead of 
> '_utc'.

Can you elaborate on the "stability" consideration?

I would like to revisit this issue since we will have some changes made to 
datetime pickles in the context of PEP 495.

--

___
Python tracker 

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



[issue9051] Improve pickle format for timezone aware datetime instances

2015-09-26 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

For now "_utc" is not a part of API. When use it in pickling, you implicitly 
make it a part of API, and should support it forever (and force other Python 
implementations to support it). As far as it looks as implementation detail, 
there is a risk that the "_utc" variable can be renamed and this will break 
pickle compatibility.

--

___
Python tracker 

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



[issue9051] Improve pickle format for timezone aware datetime instances

2015-09-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

For stability it is better to use public name 'timezone.utc' instead of '_utc'. 
Dotted names now are supported with all protocols.

> but there is still room for improvement:

Don't worry about this. When you pickle a number of datetime objects with the 
same timezone, the timezone is pickled only once and for all other datetime 
objects only a reference is used.

--
nosy: +serhiy.storchaka
type: behavior -> enhancement
versions: +Python 3.6 -Python 3.5

___
Python tracker 

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



[issue9051] Improve pickle format for timezone aware datetime instances

2014-06-30 Thread Raymond Hettinger

Changes by Raymond Hettinger raymond.hettin...@gmail.com:


--
title: Improve pickle format for aware datetime instances - Improve pickle 
format for timezone aware datetime instances

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